Past Papers – Data Structure and Algorithm

Course Title: Data Structure and Algorithm
Total Marks: 40
Time allowed: 1 Hour

   Question No. 1                                                                                          (10 Marks)                                                                                                                                                                                                                                     

  1. Write  an algorithm to sort a given data in Ascending Order by selection sorting
  2. Write  an algorithm to sort a given data in Ascending Order by Bubble sorting

data: 6, 8, 54, 2

Question 2:                                                                                          (20 Marks) 

 

  1. Consider the following operation performed on a stack of size 10:

push(a),pop( ),push(b), push(c),pop(),push(d),pop(), pop( ), push (d)

which of the following statement is correct

  1. a) overflow b)underflow c)both a & b    d) none

Note: (show the implementation graphically)

  1. If the sequence of operation are push(1), push(2), pop(),push(1), push(2),pop( ),

pop( ), pop(), push(2), pop( ) are performed on stack, the sequence of poped out values

  1. a) 2,2,1,1,2 b) 2,2,1,2,2          c) 2,1,2,2,1          d) 2,1,2,2,2

Note: (show the implementation graphically)

    

Consider the infix expression.

(4+8)*(6-5)/((3-2)*(2+2))

  1. Convert the expression to postfix
  2. Evaluate the postfix expression using stac

Consider the infix expression.

(4+8)*(6-5)/((3-2)*(2+2))

  1. Convert the expression to postfix
  2. Evaluate the postfix expression using stac

                                    Consider the infix expression.

(4+8)*(6-5)/((3-2)*(2+2))

  1. Convert the expression to postfix
  2. Evaluate the postfix expression using stac

                                    Consider the infix expression.

(4+8)*(6-5)/((3-2)*(2+2))

  1. Convert the expression to postfix
  2. Evaluate the postfix expression using stac

Question 3:                                                                                          (10  Marks)   

 

+ 1 * 122 123

 

Write a C++ program to display all elements using in array using Linear Queue data structure.

 

Prof.Fazal Rehman Shamil (Available for Professional Discussions)
1. Message on Facebook page for discussions,
2. Video lectures on Youtube
3. Email is only for Advertisement/business enquiries.