C-Dynamic Memory Allocation and Data Structure Questions and Answers

Practice Mode
Showing 10 of 104 questions
Q31
How many shifting is required to sort the elements in insertation sort in non decresing order of the given list below: int A[ ]={2,3, 7, 1, 6, 8, 9};
  • A 4
  • B 5
  • C 6
  • D None of these
Answer: Option A
Q32
How many comparison is required to search a number on a given sorted list by using binary search. int L[ ]={1, 3, 7,  9, 12, 15, 19, 21, 27, 30}; The key value is 3
  • A 3
  • B 4
  • C 5
  • D 6
Answer: Option A
Q33
The minimum number of comparisons required to determine if an integer apears more than n/2 times in a sorted array of  n integer is
  • A O(n)
  • B O(logn)
  • C O(log*n)
  • D O(1)
Answer: Option A
Q34
A program P reads in 500 integers in the range 1 to 100 representing the score of 500 students. If then prints the frequencies of each score above 50. What would be thebest way for P to store the frequencies ?
  • A An aray of 50 numbers
  • B An array of 100 numbers.
  • C An aray of 500 numbers.
  • D A dynamically allocated array of 550 numbers
Answer: Option A
Q35
In the following C function, let n e"m, int gcd (n,x) { if (n%m==0) return m; n=n%m; return gcd (m,n); } How many recursive calls re made by this function ?
  • A O (logn)
  • B O(n)
  • C O(log logn)
  • D O("n)
Answer: Option A
Q36
Consider the code fragment written in C below void f(int n) { if (n<=1) { printf("%d", n); } else { f (n/2); printf("%d", n%2); } } what does f(173 print?
  • A 010110101
  • B 010101101
  • C 10110101
  • D 10101101
Answer: Option D
Q37
Which of the following implementations will produce the same output for f(173) as theone from previous question? P1: void f(int n) { if (n/2) { f (n/2); } printf("%d:,n%2); } P2: void f(int n) { if (n<=1) { printf("%d",n); } else { printf('%d",%2); f(n/2); } }
  • A Both P1 and P2
  • B P2 only
  • C P1 only
  • D Neither P1 nor P2
Answer: Option A
Q38
A single array A[MAXSIZE] is used to implement two stacks. The two stacks grow from opposite ends of the array. Variables top1 and top2 (top1<top2) point to the location of the topmost element in each of the stacks. If the space is to be used efficiently, the condition for "stack full" is
  • A (top1=(MAXSIZE-1)/2) and (top2=(MAXSIZE-1)/2 + 1)
  • B top1 + top2=MAXSIZE
  • C (top1=(MAXSIZE-1)/2 or (top2=MAXSIZE-1)
  • D top1=top2-1
Answer: Option D
Q39
The following postfix expression with single digit opeands is evaluated using a stack: 8 2 3^ / 2 3 * + 5 1*- Note that ^ is the exponentiation operator. The top two elements of the stack after the first * is evaluated are:
  • A 6, 1
  • B 5, 7
  • C 3, 2
  • D 1, 5
Answer: Option A
Q40
The best data structure to check whether an arithmetic expression has balanced parenthesis is a
  • A Queue
  • B Stack
  • C Tree
  • D List
Answer: Option B
Questions and Answers for Competitive Exams Various Entrance Test