Make your own free website on Tripod.com
Assignment 1
Q1. Write a program/algorithm in C for finding the largest number from an array of size n.
Find the time complexity of the algorithm.

Q2. Solve the following recurrence equation
T(n)=T(n/2)+ c
T(1)=1

Q3. For the following code fragment, Find the time complexity
for (i=0; i < n; i++) {
   for(j=0; j < n; j++) {
      for (k = 0; k < n; k++) {
         A[i] = A[j] * A[k];
          }
       }
   }
Assignment 2
Q4. For an array
       data_type a [r1] [r2][r3]
(i)   Find the address of a[i][j][k] if array a is stored using row-major order.
(ii)  Find the address of a[i][j][k] if array a is stored using column-major order.

Q5. For an array
       data_type a [r1] [r2][r3]......[rn]
(i)   Find the address of a [i1] [i2][i3]......[in], if array 'a' is stored using row-major order.
(ii)   Find the address of a [i1] [i2][i3]......[in], if array 'a' is stored using column-major order.

Q6. We have an array a[12][11], base address is 1000, and each element is a float.
(i) What is the addres of a[8][10], if array is stored using row-major order?
(ii) What is the address of a[8][10], if array is stored using row-major order?

Assignment 3
Q7. Write a function to copy a string to another string.

Q8. Write a function to reverse a string.

Q9. Write a function for String Comparison i.e. compare two strings, and
output is 0, if both the strings are equal, otherwise
output is the difference of ascii value of the first character where strings differ.

Q10. Write a function for searching a string inside another string.
For help, Refer this animation in flash String Search

Assignment 4
Q11. Write a program to count the number of nodes in a linked list.

Q12. Write a program to find a node with a particular value.
For ex: You will ask the user to provide value for the node he is looking for. After you get the value, search in the linked list for the value. If you can find, then dispay "Search Successful". Else display "Search unsuccessful"

Assignment 5
Q13. Write a program to reverse a linked list.
Hint: Watch this presentation Reverse a linked list

Q14. Write a program to count the number of nodes in a circular linked list.

Q15. Write a program to insert a node in a ciruclar linked list
->Insert in the beginning of ciruclar linked list
->Insert at the end of circular linked list
->Insert in between the circular linked list

Q16.Write a program to delete a node from a circular linked list
->Delete first node from the ciruclar linked list
->Delete last node from the circular linked list
->Delete any node from the circular linked list.

Assignment 6
Q17. Evaluate the following Postfix expression using stack. Show each and every step of stack during evaluation.
(i)   3 5 2 + 2 $ 5 -- 2 + + +
(ii)  1 4 3 2 + - *
(iii)  a b c - d * + e + , where a=7; b=3; c=12; d=-5; e=1.
(iv)  a b c + - d * e -, where a=7; b=3; c=12; d=-5; e=1.

Assignment 7
Q18. Convert the following infix expression to prefix expression.
(i)2 + 3
(ii)(2 + 3) - 5
(iii)5 * ((6 + 2) - 4)
(iv)(2 * 3) / ((4 + 6) * (9 - 4))
(v)( 15 + 2 $ 3 $ 2 / (4 * ( 7 6 ) * ( 4 / 4)))
(vi)4 + ( ( 15 + 2 $ 3 $ 2 / ( 4 * ( 7 6 ) * ( 4 / 4 ) ) ) * 2)
(vii)4 + 15 + 2 $ 3 $ 2 / 4 * 7 6 * 4 / 4 * 2
Assignment 8
Q18. Convert the following infix expression to postfix expression.
(i)2 + 3
(ii)(2 + 3) - 5
(iii)5 * ((6 + 2) - 4)
(iv)(2 * 3) / ((4 + 6) * (9 - 4))
(v)( 15 + 2 $ 3 $ 2 / (4 * ( 7 6 ) * ( 4 / 4)))
(vi)4 + (  (  15  +  2  $  3  $  2  /  (  4  *  (  7  *  6  )  *  (  4  /  4  )  )  )  *  2 )
(vii)4 + 15 + 2 $ 3 $ 2 / 4 * 7 6 * 4 / 4 * 2

Assignment 9
Q19. Given an expression involving three different pairs of paranthesis "(", ")", "{", "}", "[" and "]" and other terms such as variable names and integers, the problem is to determine if the expression is well formed with respect to parentheses.

For example, the expression " a ( b * c ) - { ( c ^ d ) / g } " is well formed.
The expression, " a ( b * ) c ) - { ( c ^ d } / g )" is not well formed it has many unbalanced parenthesis in it.

Assignment 10
Q20. Sort the following list of numbers
8, 9, 3, 5, 6, 4, 2, 1, 7, 0
(i) Insertion Sort
(ii)Selection Sort
(iii)Bubble Sort
Show each step of sorting.

Q21. Write a program to implement stack using linked list.
Q22. Write a program to implement queue using arrays.
Q23. Write a program to implement queue using Linked List.
Q24. Write a program to implement circular queue using arrays.
Q25. Write a program to implement circular queue using linked list and double Linked List.