DataSturucture Objective-Questions IIISem
DataSturucture Objective-Questions IIISem
1.
4. index
a.
b.
c.
d.
1 or 3
2 and 4
Only 2
Only 4
13. Which Of the following occupies more memory with same number of elements?
a. Array
b. Single Linked list
c. Doubly Linked List
d. Queue
Ans) c
14. Recursive function implements which mechanism?
1) Queue
2) Lifo
3) Filo
4) Fifo
a. Only 1
b. 2 or 3
c. 1 or 4
d. All
Ans) b
15. Which of the following abstract data types cannot be used to represent a many to
many relation?
1) Binary Tree
2) Graph
3) Stack
a. 1 and 2
b. 2 and 3
c. 1 and 3
d. All
Ans)C
16. An Example of linear Data structures ?
1) Array
2) Stack
3) Linked List
a. 1 and 2
b. 2 and 3
c. 1 and 3
d. All
Ans)D
17. The logical picture of data type plus the specification of operations required to create
& manipulate objects of this type is known ___
a. Structure
b. Pointer
c. ADT
d. Class
Ans)C
18. In Quick sort & Radix sort except array ________data structure is used?
a. Pointer
b. Link list
c. Double link list
d. Tree
Ans)A
19. In Counter index generation ________ data structure is used
a. Deque
b. Priority Queue
c. Circular Queue
d. Linear Queue
Ans)C
20. Simulations are implemented using _______ data structure.
a. Stack
b. Queue
c. Linked list
d. Tree
Ans)B
21. The data structures you will use if you want to go to first record from the last and
vice versa______________
a. Tree
b. Linked list
c. Stack
d. Doubly linked circular list
Ans)D
22. In RDBMS, the efficient data structure used in the Internal storage representation is
a. Binary tree
b. Stack
c. B+Tree
d. Graph
Ans)C
23. Pick the appropriate statement for the data structures from the following options
a. May be helpful to develop efficient algorithms in different phases of data
processing
b. Need not give relationship between data items
c. Is programming language dependent
d. None
Ans)A
Ans)D
29. Which of the following combination of data structures used in the areas : RDBMS,
Network data model and Hierarchical data model are correct
1)RDBMS Array (i.e. Array of structures)
2)Network data model
Graph
3)Hierarchical data model Trees
a. and 2
b. 1 and 3
c. 2 and 3
d. None
Ans)C
30. Polynomials in memory may not be maintained through
1)Linked list with header node
2)One dimensional array
3)Stack
a. 2 and 3
b. 1 and 3
c. 1 and 2
d. None
Ans)C
5.
a.
Mathematical
model
Pseudo code
Language
b.
c.
d.
e.
Abstract data
type
Data Structure
Informal
Algorithm
Java program
Mathematical
model
Abstract data
type
Data structure
Informal
Algorithm
Pseudo-code
Language
Java program
Mathematical
model
Abstract data
type
Data structure
Informal
Algorithm
Java program
Pseudo code
Language
Mathematical
model
Pseudo code
language
Data structure
Abstract data
type
Java program
Informal
Algorithm
None of above
Ans : b
6.Consider the following program segment:
public void swap()
{
int x, y, z;
(i)
(ii)
(iii)
}
Identify suitable statements to fill in the blank lines of the above algorithm so that it will
interchange the values of the two variables x and y.
(a)
(b)
(c)
(d)
(e)
(i) x = y;
(i) z = x;
(i) z = x;
(i) z = y;
(i) y = z;
Ans :b,d
(ii) z = y; (iii) y = z;
(ii) x = y; (iii) y = z;
(ii) z = y; (iii) y = x;
(ii) y = x; (iii) x= z;
(ii) z = x; (iii) x = z;
b.
c.
d. Both B and C
Ans : b
13. Given the rooted tree below, which of the following is FALSE?
a. abehidcgjf
b. dbheiafcjg
c. jgfcihedba
d. abdehicfgj
Ans : d
Ans : d
____ 16. Based on the graph below, which of the following is NOT true?
a.
b.
c. is an isolated vertex
d. Both B and C
e. Both A and C
Ans : e
____ 18. A complete graph G is known to have 10 edges. Then the number of vertices must be
a. 20
b. 11
c. 5
d. 6
Ans : c
____ 19. Consider the graph below. Which of the following is the correct adjacency matrix for this graph?
a.
b.
c.
d.
Ans : b
.(TRUE or FALSE)
Ans : TRUE
a. [1] [n]
b. [0] [n]
c. [1] [n-1]
d. [0] [n-1]
Ans. : a An array may be 0 based, 1 based or n based. Now whichever it is
based on that number decides its starting and ending index.
6. How is this resolved.. Arr[2];
a. *(&Arr + 2)
b. Arr[0] + 2
c. The Second position from Arr[0]
d. *(Arr + 2)
Ans. : a. Arr always refers to the first element of the array.. and the index is
added to the base address of the array to get the result.
7. Lower bound and Upper bound of an Array represent the following element..
a. Largest and Smallest Resp.
b. Smallest and Largest + 1
c. Smallest and Largest 1
d. Smallest and Largest Resp.
Ans.: d., Lower bound represents the first element of the array and upper
bound represents the last element of the array.
8. In an Array the range specifies
e. Scope of the Array
f. Nos. of Elements in the Array
g. The Group of the Array
h. Size 1 of the Array
Ans. : b., Range Specifies the total nos of elements in an Array.
9.If Arrays upper bound is specified by U and lower bound is specified by L
then the range of the array will be.
a. U L +1
b. L + U 1
c. U L 1
d. L U + 1
Ans. :a The range of the array will be Upper - Lower + 1
10 . If Upper bound is represented by 99 and lower bound by 0 in a o based array,
then the range of the array is..
a. 0
b. 99
c. 100
d. 101
Ans. : c., Range is given by Upper Lower + 1
11. A string is ended by
char
char
char
char
char
s[8];
s[9];
s[10];
s[11];
s[12];
Ans : c, you will need 10 cells, 9 to hold the 9 characters and the last one cell
to hold the end of the string
13.
Which of the following can be used to describe arrays as well as hard disks?
a.
b.
c.
d.
e.
static
dynamic
direct access
linked access
linked
Ans. : c.
14.
Data[i]
Data(i)
Data(i,j)
Data.i
Data[i].f
Ans. : a
15. Arrays are also called as
1) Dense lists
2) Predefined variables
3) Static data structures
a. 1 and 2
b. 2 and 3
c. 1 and 3 d)All
Ans. : c
16.
POINTERS
1. An element of structure can be a Pointer; Which Points to a structure of the same type
is called ___.
a. referential pointer
b. structure pointer
c. pointer structure
d. Self-Referential Structure
Ans. : d
2.Consider the following statements:
int
int
int
i =
k =
p =
*p;
i;
k;
42;
i;
&i;
After these statements, which of the following statements will change the value of i to75?
a.
b.
c.
d.
K = 75
*k = 75;
p = 75;
*p = 75;
a.
b.
c.
d.
Ans. : d, since the last statement will change the values of i, as the *p2 which is actually j
value will be copied to *p1 i.e. i.
4. .
void main()
{
int *p1,*p2;
p1=(int *)malloc(sizeof(int));
p2=(int *)malloc(sizeof(int));
*p1=17;
*p2=153;
1st O/p
printf("\n%d.......%d..",*p1,*p2);
free( p1);
p1=p2;
2nd O/p
printf("\n%d.......%d..",*p1,*p2);
*p1=253;
3rd O/p
printf("\n%d.......%d..",*p1,*p2);
*p2=355;
4th O/p
printf("\n%d.......%d..",*p1,*p2);
}
c. 253.353
d. 353.353
Ans. : d, Since both p1 and p2 point to the same location, so when indirection of p2 is
modified, the actual value gets changed, and both the pointers indirection will yield the
same value.
5.What is printed by these statements?
int i = 1;
int k = 2;
int *p1;
int *p2;
p1 = &i;
p2 = &k;
p1 = p2;
*p1 = 3;
*p2 = 4;
printf(%d,i);
a.
b.
c.
d.
1
2
3
4
Ans. : a, Since the line p1 = p2, makes both of the pointers to point at k, so the next two
lines changes the value of k.
6.What is printed by these statements?
int i = 1;
int k = 2;
int* p1;
int* p2;
p1 = &i;
p2 = &k;
p1 = p2;
*p1 = 3;
*p2 = 4;
printf(%d,k);
a.
b.
c.
d.
1
2
3
4
Ans. : d, Since the line p1 = p2, makes both of the pointers to point at k, so the next two
lines changes the value of k and the last changed value is 4.
a.
b.
c.
d.
1
2
3
4
Ans. : c, All the dynamic memory allocation is done from the heap of the program.
9.Suppose you have the following function prototype and variable declaration:
void goop(int z[ ]);
int x[10];
Which is the correct way to call the goop function with x as the argument:
a.
b.
c.
d.
e.
goop(x);
goop(x[ ]);
goop(x[10]);
goop(&x);
goop(&x[ ]);
Ans. : a,
10. What's wrong with this code?
char *p;
*p = malloc(10);
a.
b.
c.
d.
No Error
Logical Error
Syntax Error
All of the above
Ans.: c, Memory is allocated to the pointer and not to indirection of the pointer.
11. Is there a problem with this codeif yes then what
typedef struct {
char *item;
NODEPTR next;
} *NODEPTR;
a. No Problem
b. The struct ptr cannot be defined inside the same struct
c. Problem with typedef
d. The struct has to be defined first
Ans. : c, the problem is with typedef,
struct node{
char *item;
struct node *next;
} *NODEPTR; would be correct
12. Does *p++ increment p, or what it points to
a. equivalent to *(p++)
b. equivalent to (*p)++
c. Gives Error
d. Equivalent to *(++p)
Ans. : a
13.Suppose that the goop function from the previous question changes the value of z[1].
Does this change effect the value of the actual argument?
a. Yes
b. No
Ans. : Yes, it will change.
14.Here is a function declaration:
void goo(int* x)
{
*x = 1;
}
Suppose that a is an int* variable pointing to some integer, and *a is equal to zero.
What is printed if you print *a after the function call goo(a)?
a.
b.
c.
d.
e.
0
1
address of a
address of x
None of the above
Ans. : b, The operator & as such says at the address of, it is not a separate variable to
be a pointer.
16. What is the problem if any
int array[5], i, *ip;
for(i = 0; i < 5; i++) array[i] = i;
ip = array;
printf("%d\n", *(ip + 3 * sizeof(int)));
a. No Error
b. Prints 3
c. Prints Garbage(Logical Error)
d. Syntax Error
Ans. : c, When ip+3 is calculated, since it is an int pointer it automatically
traverses to the 3rd element in the array, size of is not required.
17. What will go wrong if any,
.<Executable stmts>
void *p1, *p2;
*p1++
*p2--..
.<Executable stmts>
a. No error
b. Pointers Cannot have Additions and subtractions
c. Void Pointers cannot undergo any arithmetic operation
d. Syntax Logic is correct But syntax is a problem
Ans. : c, Void pointers cannot undergo ANY because the size of the pointing
object is unknown.
18. In the statement
Char * p1, p2;
a. Both are pointers
b. Only p1 is a char pointer but p2 is not
*i, *j, k;
k = 4;
j = &k;
i = &j;
20. printf(%d,j);
a.
b.
c.
d.
4
2006
2008
Error
Ans. : c
21. printf(%d,*j);
a.
b.
c.
d.
4
2006
2008
Error
Ans. : a
22 . printf(%d,*i);
a. 4
b. 2006
j
2008
2006
k
4
2008
c. 2008
d. Error
Ans. : c
23. printf(%d,**i);
a.
b.
c.
d.
4
2006
2008
Error
Ans. : a
24. printf(%d,&k);
a.
b.
c.
d.
4
2006
2008
Error
Ans. : c
25. printf(%d,&j);
a.
b.
c.
d.
4
2006
2008
Error
Ans. : b
26. printf(%d,&i);
a.
b.
c.
d.
2004
2006
2008
Error
Ans. : a
27. The pointer that may point to a structure of same type as the structure is called
as______
a.
b.
c.
d.
Ans)B
Referential pointer
Self-Referential Pointer
Structure pointer
Pointer structure
28. Assume Memory location = 100 (decimal). What happens when we write:
ptr + 1;(ptr is pointing to an integer variable)
a.
b.
c.
d.
1
23
Garbage
Error
1
23
2
Error
Ans. : c, Since it is p+1, first p will be de- referenced then the value got will
be incremented, so 2.
31.
1
23
Garbage
Error
Nothings Wrong
Error because of initialization
Error because of the pointer
Syntax Error
Ans. : a, One of the difference between calloc and malloc is that calloc initializes
the allocated memory.
34.
Ans. : d, The second argument in calloc is the one which determines what the
allocated space is supposed to be initialized to.
35.
Ans. : b, One of the difference between calloc and malloc is that malloc does not
initialize the allocated memory.
36.
The command to free the memory reserved during the running of the program is:
a.
b.
c.
d.
realloc()
calloc()
malloc()
free()
Ans. : d, free actually frees the memory or returns the memory back to the heap.
38.
Referencing Operator
Dereferencing Operator
Memory Allocation Operator
Memory freeing operator
Referencing Operator
Dereferencing Operator
Memory Allocation Operator
Memory freeing operator
a. Creates an error
b. No problem with this
c. It will create a logical error since void pointer.
d. The address will be stored but the pointer will anyways be of one byte.
Ans. : b, No problem with this because although a generic pointer but is type
casted.
46. int func(int a, float b);
This is a prototype of which argument passing type,
a. Pass by Value
b. Pass by Reference
c. Call by Reference
d. It generates an Error.
Ans. : a, This is an example of pass by value
47. int func(int *a, float *b);
This is a prototype of which argument passing type,
a. Pass by Value
b. Pass by Reference
c. Call by Reference
d. It generates an Error.
Ans. : b, This is an example of pass by value
48. The term pointee in pointer assignment is used to indicate __________.
a. The pointed location
b. The location of the pointer
c. There is no term as pointee
d. The term does not deal with pointers.
Ans. : a, pointee is basically the location which the pointer is pointing to.
Refn. : http://cslibrary.stanford.edu/102/PointersAndMemory.pdf
49. What are two pointers pointing to the same location called.
a. Multiple Pointers
b. Sharing Pointers
c. Sharing Pointees
d. Multiple Pointees
Ans. : b, two pointers sharing the same pointee are known as sharing pointers.
Refn. : http://cslibrary.stanford.edu/102/PointersAndMemory.pdf
50. What is the solution called if two functions share the same copy of memory without
actually copying the memory into their respective space allocated.(In C)
a. Pass by reference
b. Pass by value
c. Deep Copying
d. Shallow Copying
Ans. : d, Shallow copying is a technique in which more than one function refer
to the same location by using a pointer each, both of which point to the same
pointee. Refn. : <Same .pdf used in as previous one.>
51. What is the technique known as in which the complete memory location is passed to
the functions, where each function has its own copy of the memory it wants to
access and is even free to edit, which was not available with shallow copying.
a. Pass by reference
b. Pass by value
c. Deep Copying
d. Shallow Copying
Ans. : c, Deep Copying, Refn. Is the same pdf as above.
52. What is a bad pointer?
a. A pointer which do not have any pointee, initially.
b. Its similar to dangling pointer
c. No term as bad pointer exists
d. A pointer pointing to a corrupt location
Ans. : a, Every pointer when initialized is actually a bad pointer, because it
does not point to any location and bad pointers differ from dangling pointers
by, the fact that dangling pointers first points to a location and then without
dereferencing the location if deleted, the pointer becomes dangling.
53. What is a dangling pointer?
a. A pointer which do not have any pointee, initially.
b. Its similar to bad pointer
c. No term as dangling pointer exists
d. A pointer pointing to a location, which does not exist anymore.
Ans. : d, Explanation is same as of the bad pointer.
54. Consider the code snippet,
void eg( )
{
int *p;
*p = 45;
printf(%d,*p);
}
a. Program has a syntax error.
b. It generates an error on runtime.
c. It works perfectly fine with 45 being printed on the screen.
d. The pointer does not get dereference in the printf statement
Ans. : b, it generates a runtime error, pointer cannot point to data as such, it
can only point to locations.
55. What will be the o/p
void main()
{
int *x,*y;
x = (int *)malloc(sizeof(int));
*x = 42;
y = x;
*y = 24;
printf("%d",*x);
}
a. Generates a syntax error
b. Generates a runtime error
c. Prints 42 on console
d. Prints 24 on console
Ans. : d, prints 24 on console.
56. Consider the code..
void main()
{
int *x,*y;
x = (int *)malloc(sizeof(int));
*x = 42;
y = x;
printf("%d",*y);
}
a.
b.
c.
d.
Ans. : a, Generates a syntax error, malloc will return a void pointer, it has
to be typecasted.
void main()
{
int *x,*y;
x = (int *)malloc(sizeof(int));
*x = 42;
y = x;
*y = 24;
printf("%d,%d,x,y);
}
a.
b.
c.
d.
42, 24
24 , 24
409863, 409863
409863, 409865
Ans. : c, both will print the same address on the console, that in this case is
409863.
59.
void victim() {
int *ptr;
ptr = tab();
printf(%d,*ptr);
}
a.
b.
c.
d.
Nothing Happens
A runtime Error occurs
Memory Leak
Automatic de allocation happens
Ans. : c, memory leak will occur, i.e. the function will exit for that time but
the memory will not be allocated for any further requirements.
61. Memory to the pointer is allocated from
a.
b.
c.
d.
Ans. : a, memory newly allocated is always allocated from the program heap.
Consider the piece of code :
void main()
{
int *p1,*p2;
p1=(int *)malloc(sizeof(int));
p2=(int *)malloc(sizeof(int));
*p1=17;
*p2=153;
1st O/p
printf("\n%d.......%d..",*p1,*p2);
free( p1);
p1=p2;
2nd O/p
printf("\n%d.......%d..",*p1,*p2);
*p1=253;
3rd O/p
printf("\n%d.......%d..",*p1,*p2);
*p2=355;
4th O/p
printf("\n%d.......%d..",*p1,*p2);
}
17 153
17.<Garbage>
<Garbage>.153
<Garbage>.<Garbage>
Ans. : a, It at no time on the 1st output give garbage value, both the
pointers have been assigned proper values.
63.
64.
a.
b.
c.
d.
17..153
153..153
253..253
253..153
1
23
Garbage
Error
Ans. : a, first de-referencing will take place then increments will happen. Since it is p++,
the value of the pointer will be incremented in the next stmt.
1. A Stack is a _______ DS
2.
3.
4.
5.
6.
7.
a. LIFO
b. FIFO
c. LILO
d. FILO
Ans. : a, d : A Stack is a Data Structure behaving Last in And First out or First
In and Last Out.. They are one and the Same...
In a Stack the elements are entered from ________.
a. End
b. Top
c. Random
d. Bottom
Ans. : b. , The elements are entered and deleted from the stack from the top
only.
The basic Operations on the Stack are
a. Push & Pop
b. Insert & Delete
c. Enter & Remove
d. Add & Subtract
Ans. : a, Push and Pop are the terminologies used in use of the stack.
Condition Checked before Pushing
a. Stack Overflow
b. Stack Underflow
c. No Condition to be checked
d. Both the conditions
Ans . : a. : Check Stack Overflow before pushing.
Condition Checked before Poping
a. Stack Overflow
b. Stack Underflow
c. No Condition to be checked
d. Both the conditions
Ans . : b. : Check Stack Underflow before poping.
The total nos of pair of brackets in an expression is called _______
a. Open Scopes
b. To be closed Scopes
c. Nesting Depth
d. Depth Sequence
Ans. : c Nesting Depth is the total nos. of open brackets in an expression at
any time to be closed.
Stacks are implemented using _________.
a. Arrays
b. Linked Lists
c. Static Variables
d. Register Variables
Ans. : a, b, Stack are implemented using arrays as well as linked list.
8.
add
append
insert
push
serc
carpets
steprac
ccaarrppeettss
Ans. : c, After working out it comes out to be steprac since stack is a last in
first out system.
15. Here is an INCORRECT pseudo code for the algorithm which is supposed to
determine whether a sequence of parentheses is balanced:
declare a character stack
while ( more input is available)
{
read a character
if ( the character is a '(' )
push it on the stack
else if ( the character is a ')' and the stack is not empty )
pop a character off the stack
else
print "unbalanced" and exit
}
print "balanced"
Which of these unbalanced sequences does the above code think is balanced?
a.
b.
c.
d.
((( ))
( ))(( )
(( )( )))
(( )))( )
a.
b.
c.
d.
e.
1
2
3
4
5
c. B(i-1) = T(i+1)
d. B(i-1) = T(i-1)
Ans)B
30. what type of storage is used to represent stacks and queues
a. Random
b. Sequential
c. Dynamic
d. Logical
Ans : b , page 186 Tenenbaum 2nd edition(2002)
31. Drawbacks of sequential storage in stacks
a. Fixed amount of storage remains allocated to the stack
b. No more than fixed amount of storage can be allocated to the stack
c. Both a) and b)
d. None
Ans : c, page 187 Tenenbaum 2nd edition(2002)
32. what is the infix expression of the given prefix expression : +A*BC
a.
b.
c.
d.
A*B+C
A+B*C
(A+B)*C
A*(B+C)
((A+B-C)*D)$(E*F)
A+B-C*D$E*F
A+(B-C)*D$(E*F)
((A+B)-C*D)$E*F
a.
b.
c.
d.
(A*B+C)$(A+B)*C
(A+B*C)$((A+B)*C)
A+(B*C)$A+(B*C)
(A+B)*C$A+(B*C)
ABCDEF-*$*+
ABC-DE*F$*+
AB-CDEF$**+
ABC-DEF*$*+
d. A*(B+C)
Ans : b, Page no 242.Tenenbaum 1994 edition
41. what is the infix expression of the given Postfix expression : AB+C*
a. A*B+C
b. A+B*C
c. (A+B)*C
d. A*(B+C)
Ans : c, Page no 242.Tenenbaum 1994 edition
42. what is the infix expression of the given Postfix expression : ABC-DEF*$*+
a. ((A+B-C)*D)$(E*F)
b. A+B-C*D$E*F
c. A+(B-C)*D$(E*F)
d. ((A+B)-C*D)$E*F
Ans : c, Page no 242.Tenenbaum 1994 edition
43. what is the infix expression of the given Postfix expression : ABC*+AB+C*$
a. (A*B+C)$(A+B)*C
b. (A+B*C)$((A+B)*C)
c. A+(B*C)$A+(B*C)
d. (A+B)*C$A+(B*C)
Ans : b, Page no 242.Tenenbaum 1994 edition
44. what is the postfix expression of the given Infix expression : A+B*C
a. ABC*+
b. AB+C*
c. AB*C+
d. ABC+*
Ans : a, Page no 242.Tenenbaum 1994 edition
45. what is the postfix expression of the given Infix expression : (A+B)*C
a. ABC*+
b. AB+C*
c. AB*C+
d. ABC+*
Ans : b, Page no 242.Tenenbaum 1994 edition
46. what is the postfix expression of the given Infix expression : A+(B-C)*D$(E*F)
a. ABCDEF-*$*+
b. ABC-DE*F$*+
c. AB-CDEF$**+
d. ABC-DEF*$*+
Ans : d, Page no 242.Tenenbaum 1994 edition
47. what is the postfix expression of the given Infix expression (A+B*C)$((A+B)*C)
a. ABCABC*++*$
b. ABC+*AB+C*$
c. ABC*+AB+C*$
d. AB+C*AB+C*$
Ans : c, Page no 242.Tenenbaum 1994 edition
48. what is the Prefix expression of the given postfix expression : ABC*+
a. +A*BC
b. +AB*C
c. +*ABC
d. *+ABC
Ans : a, Page no 242.Tenenbaum 1994 edition
49. what is the Prefix expression of the given Postfix expression : AB+C*
a. +A*BC
b. +AB*C
c. +*ABC
d. *+ABC
Ans : d, Page no 242.Tenenbaum 1994 edition
50. what is the Prefix expression of the given Postfix expression : ABC-DEF*$*+
a. +*-$*ABCDEF
b. A+*-BCD$*EF
c. +A*-BC$D*EF
d. +*-ABC$*DEF
Ans : c, Page no 242.Tenenbaum 1994 edition
51. what is the Prefix expression of the given Postfix expression : ABC*+AB+C*$
a. $+**+ABCABC
b. $+A*BC*+ABC
c. $+*ABC*+ABC
d. +*ABC$*+ABC
Ans : b, Page no 242.Tenenbaum 1994 edition
52. what is the Prefix expression of the given Infix expression : A+B*C
a. +AB*C
b. +*ABC
c. *+ABC
d. +A*BC
Ans : d, Page no 242.Tenenbaum 1994 edition
53. what is the Prefix expression of the given Infix expression : (A+B)*C
a. *+ABC
b. +A*BC
c. +AB*C
d. +*ABC
Ans : a, Page no 242.Tenenbaum 1994 edition
54. what is the Prefix expression of the given Infix expression : A+(B-C)*D$(E*F)
a. +*-$*ABCDEF
b. A+*-BCD$*EF
c. +*-ABC$*DEF
d. +A*-BC$D*EF
Ans : d, Page no 242.Tenenbaum 1994 edition
55. what is the Prefix expression of the given Infix expression :(A+B*C)$((A+B)*C)
a. $+**+ABCABC
b. $+*ABC*+ABC
c. $+A*BC*+ABC
d. +*ABC$*+ABC
Ans : c, Page no 242.Tenenbaum 1994 edition
56) Consider the following statements.
(i) A stack is a list with the restriction that items are inserted or removed/deleted only at
one position, namely the end of the list.
(ii) The general model is that one where there is some element that is at the top of the
stack, and it is the only element that is visible.
(iii) A pop or top on an empty stack is generally considered an error in the stack ADT.
(iv) The fundamental operations on stacks are push and pop, where push is relevant to the
removal of the most recently inserted element and pop is equivalent to an insertion.
(v) A stack is a list; insertion and deletion can be performed from both ends.
Which of the above statements is/are valid for stacks?
a.
b.
c.
d.
Choose the best definition from Part B for the above four operations respectively in Part A.
(a) (i)->p (ii)->r (iii)->q (iv)->s
(b) (i)->s (ii)->q (iii)->r (iv)->p
(c) (i)->s (ii)->p (iii)->q (iv)->r
(d) (i)->p (ii)->s (iii)->q (iv)->r
(e) (i)->p (ii)->r (iii)->s (iv)->q
Ans : d
2. The following postfix expression S and the initial values of
the variables are.
S=AB-C+DEF-+^
Assume that A=3, B=2, C=1, D=1, E=2, F=3
What would be the final output of the stack?
(a) 1
(b) 2
(c) 0
(d) -1
(e) 3
Ans : a
3.
Which of the above data structure(s) is/are more suitable to implement polynomials?
a.
Singly linked lists
b.
Hash tables.
c.
Binary search trees and AVL trees.
d.
Priority queues.
Ans : a
+ Addition
- Subtraction
* Multiply
/ Division
$ Exponential
Correct postfix string is?
(a) A+BC-D*EF$+
(b) ABC-=D*EF=$
(c) ABC=-D*EF=$
(d) A+B-CD*E+F$
(e) AB-C+D*EF+$
Ans : e
7. Consider the following arithmetic expression P written in postfix notion
P=5, 6, 2, +, *, 12, 4 , /, (Commas are used to separate the elements of p so that 5,6,2 is not interpreted as the
number 562)
Which of the following statement(s) is/are correct?
(a) Equivalent infix is 5*(6+2)-12/4
(b) Final stack value is 37
(c) There is one stack intermediate value. It is equal to 40
(d) One of the stack intermediate value is 32
(e) Equivalent infix is 95*(6+2)-12)/4
Ans : a b
8. Consider the following stack of characters, where STACK is allocated N=8 memory
cells:
STACK : A, C, D, F, K, --, --, -(For notational convenience, we use "--" to denote an empty cell).
What is the final STACK after performing the following operations?
POP(STACK,ITEM)
POP(STACK,ITEM)
PUSH(STACK,L)
PUSH(STACK,P)
POP(STACK,ITEM)
PUSH(SATCK,R)
PUSH(STACK,S)
POP(STACK,ITEM)
(a) A, C, D, L, R, S -- ,-(b) A, C, D, L, R ,-- , --, -(c) A, ITEM, ITEM, L, P, R , S
(d) --, --, L, P, --, R, S, -(e) None of these
Ans : b
9.A stack is defined in terms of operations. The stack operations and definitions are as
follows:
(i) clear() clear the stack
12.It is required to give top element and pop a stack under the linked list implementation
of stacks using the following steps.
(i) {
(ii) }
(iii) return topItem ;
(iv) if (isempty ( ) )
(v) object topItem = topOfStack.element ;
(vi) topOfStack = topOfStack.next ;
(vii) return null ;
(viii) public objectTopAndPop( )
What is/are the correct order of the routine?
(a) (i), (iii), (ii), (iv), (vi), (v), (ii), (vii)
(b) (viii), (i), (iii), (iv), (vi), (v), (ii), (vii)
(c) (viii), (i), (iv), (vii), (vi), (v), (iii), (ii)
(d) (viii), (i), (iv), (vii), (v), (vi), (iii), (ii)
(e) (i), (viii), (iv), (i), (vii), (v), (vi), (iii), (ii)
Ans : c,d
13. Compilers check your programs for syntax errors; but frequently a lack of one
symbol (such as a missing brace or comment starter) will cause the compiler to spill out a
hundred lines of diagnostics without identifying the real error. For simplicity, we will
just check for balancing of parentheses, brackets, and braces and ignore any other
characters that appear. Then, the following steps are involved.
(i) Read characters until end of the file
(ii) Push it into the stack
(iii) Make an empty stack
(iv) If it is a closing symbol, then if the stack is empty report an error
(v) Report an error
(vi) At the end of file, if stack is not empty, report an error
(vii) If character is an opening symbol
(viii) Otherwise, pop the stack. If the symbol popped is not the corresponding opening
symbol, then
What is the correct order of the balancing symbols algorithm?
(a) (iii), (i), (vii), (iv), (ii), (viii), (v), (vi)
(b) (i), (iii), (iv), (vii), (ii), (v), (viii), (vi)
(c) (iii), (i), (vii), (ii), (iv), (v), (viii), (vi)
(d) (i), (iii), (vii), (ii), (iv), (viii), (v), (vi)
(e) (iii), (i), (vii), (ii), (iv), (viii), (v), (vi)
Ans : e
14. Which of the following is correct in respect of the above statements regarding stacks?
(a) (i) only
(b) (ii) only
(c) (i) and (iii) only
(d) (i) ,(ii)and (iv) only
(e) (i) and (iv) only
Ans : d
15. Consider the following infix expression:
(A+B)*(C-D)
Equivalent (i) postfix (ii) prefix expression(s) is/are
(ii) AB+CD-*
(ii) *AB-+CD
(ii) *+ABC-D
(ii) *+AB-CD
(ii) *+AB-CD
P=5,5,6,*,-,4,4,/+,4
If the P above is evaluated using a stack, what is the final output value on the top of the
stack?
(a) 26
(b)26,4
(c)4
(d) 12
(e) 5
Ans : c
17. Consider the following four statements.
(i) A stack is an ordered collection of items into which new items may be inserted and
from
which items may be deleted at the one end called top of the stack.
(ii) A stack is an ordered collection of items into which new items may be inserted into
an
arbitrary location.
(iii) Dynamic implementation stacks using Java language are practically impossible.
(iv) One of the stack applications is used in complier design.
Which one of the following is correct in relation to the stacks?
(a) (i) and (iv) only
(b) (i), (ii) and (iii) only
(c) (i) only
(d) (iv) only
(e) (i), (ii) and (iv) only
Ans : a
18. Consider the following infix expression:
(( A+B) * C (D-E)) ^(F + G)
Which of the following is a / are correct equivalent expression(s) for the above?
(a) ^ - * + A B C D E F G+
(b) ^ - * + A B C D E F+ G
(c) ^ - * + A B C D E + F G
(d) - ^ * + A B C D E + F G
(e) ^ - * + A B C D E + F G
Ans : c, e
19. Which of the following statements is/are correct in connection with stacks?
(a) Return and remove the most recently inserted item from the stack, if stack is not
empty.
(b) Insert a new item to the top of the stack, if stack is full.
(c) Elements can be deleted from both ends.
(d) Linked list based stack implementations are more convenient than array based
implementations.
(e) Return and remove the least recently inserted item from the stack, if stack is not
empty.
Ans : a,d
20. Which of the following is a / are possible operation(s) in connection with stacks?
(a) Reverse the order of elements on stack S using two additional stacks.
(b) Reverse the order of elements on stack S using additional variables.
(c) Reverse the order of elements on stack S using one stack and some additional queues.
(d) Sort the elements of stacks using one additional stack.
(e) Reverse the order of elements on stack S using one additional queue.
Ans : a, b, c, e
21)The following postfix expression S and the initial values of
the variables are.
S=AB-C+DEF-+^
Assume that A=3, B=2, C=1, D=1, E=2, F=3
If the above S is evaluated using a stack, what is/are the intermediate value(s) on the top
of the stack?
(a) 3
(b) 0
(c) 2
(d) -1
(e) -2
Ans : a, b, c, d
b.
c.
d.
ABDC
DCAB
DCBA
Ans : d, Queue works on the idea of first in last out, so the order is reversed.
3. Suppose we have a circular array implementation of the queue class, with ten
items in the queue stored at data[2] through data[11]. The CAPACITY is 42.
Where does the push member function place the new entry in the array?
a. data[1]
b. data[2]
c. data[11]
d. data[12]
Ans. : d since it is in an array implementation, data will be stored in the next
free index, i.e. 12th.
4. Consider the implementation of the queue using a circular array. What goes
wrong if we try to keep all the items at the front of a partially-filled array (so that
data[0] is always the front).
a. The constructor would require linear time.
b. The get_front function would require linear time.
c. The insert function would require linear time.
d. The is_empty function would require linear time.
Ans. :c, The insert function will require linear time, because the deletion has
always to happen from the front and to maintain the front on data[0].
5. In the circular array version of the queue (with a fixed-sized array), which
operations require linear time for their worst-case behavior?
a. front
b. push
c. empty
d. None of these operations require linear time.
Ans. : b, Since it is a circular queue, it will first check whether the queue is
actually empty, which might not be the case always.
6. If data is a circular array of CAPACITY elements, and last is an index into that
array, what is the formula for the index after last?
a. (last % 1) + CAPACITY
b. last % (1 + CAPACITY)
c. (last + 1) % CAPACITY
d. last + (1 % CAPACITY)
Ans. : c, This expression will point to the field after last that will be the first
field.
7. I have implemented the queue with a circular array, keeping track of first, last,
and count (the number of items in the array). Suppose first is zero, and last is
CAPACITY-1. What can you tell me about count?
a. count must be zero.
b. count must be CAPACITY.
c. count could be zero or CAPACITY, but no other values could occur.
d. None of the above.
Ans. : b, count is nothing but indicates CAPACITY, i.e. it has CAPACITY
nos. of elements.
8. I have implemented the queue with a linked list, keeping track of a front pointer
and a rear pointer. Which of these pointers will change during an insertion into a
NONEMPTY queue?
a. Neither changes
b. Only front_ptr changes.
c. Only rear_ptr changes.
d. Both change.
Ans. : c, since in a queue the entry is made from only the rear end, on
insertion of an element the rear pointer will move forward.
9. I have implemented the queue with a linked list, keeping track of a front pointer
and a rear pointer. Which of these pointers will change during an insertion into an
EMPTY queue?
a. Neither changes
b. Only front_ptr changes.
c. Only rear_ptr changes.
d. Both change.
Ans. : d, Since it is an empty queue the front and rear are initialized to -1, so
on insertion both the pointers will change and will point to 0.
10. Suppose top is called on a priority queue that has exactly two entries with equal
priority. How is the return value of top selected?
a. The implementation gets to choose either one.
b. The one which was inserted first.
c. The one which was inserted most recently.
d. This can never happen (violates the precondition)
Ans. : d, A priority queue is created keeping the fact in mind that two
elements should not have the same priority.
11. Which of the following is/are not (a) valid queue application(s)?
(a) When printing jobs are submitted to printer
(b) Lines at tickets counters
(c) Evaluating a mathematical expression
(d) Calls to large companies, when all lines are busy
(e) When there are many network set-ups of personal computers in which the disk is
allocated to one machine, known as the file server and users on the other machine are
given access to the file.
Ans) C
12. A queue in which we can insert or delete elements from both ends is called
a. Circular Queue
b. Deque
c. Double
d. single
Ans)B
13. In which queue we can utilize location of deleted element again is called
a. Circular Queue
b. Tree
c. Stack
d. None
Ans)A
14. The time complexity of adding an element to a queue of n elements is?
a. O(1)
b. O(n)
c. O(n+1)
d. None
Ans)A
15.
Ans)C
17. Pick the appropriate match for the Queue form the following options
a. Can be created by setting up an ordinary contiguous array to hold the items
b. Can take care of delete operation automatically
c. Need a pointer to handle addition and deletion of an item
d. None.
Ans)C
18.
Suppose u opened a notepad, a music player, an excel sheet, and also u are
doing your data structure programming simultaneously. Your Windows-XP
implements ______ data structure for it
tree
stack
linked list
QUEUE
(a) If Front advances past the last array position, it is reset to the first array position.
(b) If Rear advances past the last array position, it is reset to the first array position.
(c) Both (a) and (b)
(d) Neither (a) nor (b)
Ans) C
23)Consider the following queue with the indicated initial states and series of queue
operations
If the above series of operations is performed, what is the final status of the queue?
Ans) D
is forced off first, and the student who has been in the waiting list the longest is the next
user to be allowed on.
Identify the more suitable data structure to apply to the above phenomena from among
the following:
(a) Stacks
(b) Queues
(c) Tables
(d) Graphs
(e) Binary search trees
ans : b
7. Consider the following statements:
(i) The queue can be implemented by a linked list.
(ii) The queue can be implemented only by stack.
(iii) There are references kept at both the front and the back of the list.
(iv) The Queue can be implemented only by an array-based method.
Which of the above statement(s) is/are valid for the queues?
(a) (i) only
(b) (i),(ii) and (iii) only
(c) (i) and (iii) only
(d) (i),(iii) and (iv) only
(e) (ii) and (iv) only
Ans : c
8. Consider the following paragraph in connection with priority queues.
The priority queue is a (i) in which the intrinsic ordering of elements does
determine the result of its basic operations. An ascending/descending priority queue is a
collection of items which can be inserted (ii) and from which only
the.(iii)item can be removed.
Correct answers for the blank positions are
(a) ( i) tree
(ii) highest (iii) smallest
(b) ( i) data structure (ii) arbitrary (iii) largest
(c) (i) data structure (ii) arbitrary (iii) smallest
(d) (i) data structure (ii) largest (iii) smallest
(e) (i) tree
(ii) arbitrary (iii) smallest
Ans : b, c
9. The following shows a series of queue operations:
(i) enqueue(5);
(ii) enqueue(3);
(iii) dequeue( );
(iv) enqueue(7);
(v) dequeue( );
(vi) front();
(vii) dequeue( );
(viii) dequeue( );
(ix) isempty( );
(x) enqueue(9);
(xi) enqueue(7);
(xii) size( );
(xiii) enqueue(3 );
(xiv) enqueue(5)
(xv) dequeue( );
If the above series of operation is executed, what is/are the intermediate output values(s)
that is/are not returned?
(a) 11
(b) Error
(c) False
(d) True
(e) 6
Ans : a, c, e
10. Which of the following operation(s) is/are supporting Priority queues?
(a) Remove the largest item.
(b) Replace the largest with a new item (unless the new item is the largest).
(c) Change the priority of an item.
(d) Remove any item.
(e) Insert any item.
Ans : a, b, c, e
11. The basic queue operations are given in List A and a larger number of definitions is
given in List B as follows:
List A
(i)
(ii)
(iii)
(iv)
List B
Makeempty( )
enqueue(x)
dequeue( )
getfront( )
(p)
(q)
(r)
(s)
(t)
(u)
Choose the best definition from List B for each of the above four operations respectively
in List A.
(a) (i)-->p, (ii)-->r, (iii)-->q, (iv)-->t
(b) (i)-->p, (ii)-->r, (iii)-->u, (iv)-->s
(c) (i)-->p, (ii)-->r, (iii)-->u, (iv)-->t
(d) (i)-->p, (ii)-->r, (iii)-->q, (iv)-->s
(e) (i)-->p, (ii)-->r, (iii)-->u, (iv)-->t
Ans : a
12. Consider the following straight queue which can be allocated eight
integers and five operations.
front = 3 rear= 5
a.
b.
c.
d.
Ans)D
Linear Queue
Priority Queue
Circular Queue
Input restricted Deque
f(________ head_ptr);
Precondition: head_ptr is a head pointer for a linked list.
Postcondition: The function f has done some computation with
the linked list, but the list itself is unchanged.
node
const node
node*
const node*
Ans. : c, since the linked list is not changing, it does not matters if we accept
the node ptr as a formal argument
5. Suppose that f is a function with a prototype like this:
void f(________ head_ptr);
// Precondition: head_ptr is a head pointer for a linked list.
// Postcondition: The function f has done some manipulation of
// the linked list, and the list might now have a new head node.
d. None
Ans)A
13. Implementation of priority queue
1) Tree
2) Linked list
3) Doubly linked list
a. 1 and 2
b. 2 and 3
c. 1 and 3
d. All
Ans)B
14. Null pointer is used to tell
1) End of the linked list
2) Empty pointer field of a structure
3) The linked list is empty
a. 1
b. 2 and 3
c. 1 and 3
d. All
Ans)A
15. Single link list performs which of the following methods
1) Insertion
2) Modification
3) Searching
a. 1 and 2
b. 2 and 3
c. 1 and 3
d. All
Ans)D
16. The list with no node is called as
1) Empty list
2) Null list
3) Zero list
a. 1 and 2
b. 2 and 3
c. 1 and 3
d. All
Ans)A
17. An application that make use of Multilinked Structures Is_________?
a. Sparse matrix
b. Linked list
c. Tree
d. Stack
Ans)A
18. Given a arbitrary pointer to an element in a singly linked list, the time complexity
for its deletion ___________.
a. O(n/2)
b. O(n*n)
c. O(n)
d. O(n*n/2)
Ans)C
19. In C language to implement the heterogeneous linked list__________ pointer is
used.
a. Void
b. Null
c. Int
d. Structure
Ans)A
20. Searching a linked list requires linked list be created
a. In sorted order only
b. In any order
c. Without under flow condition
d. None
Ans)B
21. In linked list the logical order of elements
a. Is same as their physical arrangement
b. Is not necessarily equivalent to their physical arrangement
c. Is determined by their logical arrangement
d. None
Ans)B
22. According to Storage strategies Linked list is a
a. Nonlinear
b. Linear
c. Sequential
d. dynamic
Ans : a
23. Implementation of a list in a dynamic fashion is
a. To call upon the system to allocate and free storage may not be time consuming
b. A set of nodes not reserved in advance for use
c. The address computation is complex
d. None
Ans)B
24. If you are using C language to implement a heterogeneous linked list, the pointer
type u will prefer is ________
a. int*
b. Null
c. void*
d. float*
Ans)C
25. Which of the following statement is true
a. The next address field of the node can be empty
b. A list can exist with no nodes
c. In a singly linked list the starting address of the list is stored in the address
field of the last node
d. All of the above
Ans : c
29.What is an ordered list
a. where the address is ordered
b. where the smaller items precede the larger ones
c. both a and b
d. none
Ans : b
30.According to Access strategies Linked list is a
a. Nonlinear
b. Linear
c. Sequential
d. dynamic
Ans : b
31.How many nodes are accessed, on the average, in inserting a new element into an
ordered list with n nodes
a.(n+1)/2
b.n/2
c.1/(n+1)
d.None
a. Random access.
b. Insertion
c. Deletion
d. Insertion at end
Ans)A
Exp) Linked lists permit insertion and removal of nodes at any point in the list in constant time,
but do not allow random access.For more refer to http://en.wikipedia.org/wiki/Linked_list
40) __________ permits insertion and removal of nodes at any point in the list in
constant time, but do not allow random access
a. Stack
b. Linked list
c. Queue
d. Priority queue
Ans)B
Exp) Linked lists permit insertion and removal of nodes at any point in the list in constant
time, but do not allow random access.For more refer to
http://en.wikipedia.org/wiki/Linked_list
41) To traverse a___________, you begin at any node and follow the list in either
direction until you return to the original node.
a. Doubly linked list
b. Two way linked list
c. Circular linked list
d. Singly linked list
Ans) C
You begin at any node and follow the list in either direction until you return to the
original node, to traverse a circular linked list. Doubly linked lists and two way linked
lists are the same. For more refer to http://en.wikipedia.org/wiki/Linked_list
42) The pointer, in case of a circular linked list, pointing to the whole list is usually called
the___________.
a. Double pointer
b. List pointer
c. Circular pointer
d. End pointer
Ans )D
The pointer, in case of a circular linked list, pointing to the whole list is usually called the
end pointer. For more refer to http://en.wikipedia.org/wiki/Linked_list
43) In a ______________, each node has one link, similarly to an ordinary singly-linked
list, except that the next link of the last node points back to the first node.
a. Doubly linked list
b. Singly-circularly-linked list
c. Doubly circular linked list
d. Two way linked list
Ans) B
Each node has one link, similarly to an ordinary singly-linked list, except that the next
link of the last node points back to the first node, in a singly circularly linked list. For
more refer to http://en.wikipedia.org/wiki/Linked_list
44) In a______________, each node has two links, similarly to doubly-linked list, except
that previous link of the first node points to the last node and the next link of the last node
points to the first node.
a. Doubly-circularly-linked list
b. Doubly linked list
c. Singly-circularly-linked list
d. Two way linked list
Ans) A
Each node has two links, similarly to doubly-linked list, except that previous link of the
first node points to the last node and the next link of the last node points to the first node
in a doubly-circularly-linked list. For more refer to
http://en.wikipedia.org/wiki/Linked_list
45) In a __________, insertions and removals can be done at any point with access to any
nearby node.
a. Doubly-circularly-linked list
b. Doubly linked list
c. Singly-circularly-linked list
d. Two way linked list
Ans) B
For more refer to http://en.wikipedia.org/wiki/Linked_list
46) _______________are most useful for describing naturally circular structures, and
have the advantage of regular structure and being able to traverse the list starting at any
point.
a. Doubly linked list
b. Two way linked list
c. Singly linked list
d. Circular linked list
Ans) D
47)Which of the following operations is not efficiently supported by a singly-linked list?
a. Accessing the element in the current position
b. Insertion after the current position
c. Insertion before the current position
d. Moving to the position immediately following the current position
e. All of the above are efficiently supported
Ans.: c, To insert before the current position another pointer has to be made to point to
the position before the current position.
48) The header node of a linked list
(a) Simplifies deletion
(b) Simplifies insertion
(c) Points to null
(d) Both (a), (b)
Ans) D
49) If a header node is used, which of the following indicates a list L with one item?
(a) L.Header.Next = null
(b) L.Header.Next /= null
(c) L.Header.Next /= null and then L.Header.Next.Next /= null
(d) L.Header.Next /= null and then L.Header.Next.Next = null
(e) None of the above
Ans)D
50) Insertion of a node into a doubly linked list requires how many changes to various
Next and Prev pointers?
(a) No changes
(b) 1 Next, 1 Prev
(c) 2 Next, 2 Prev
(d) 3 Next, 3 Prev
(e) None of the above
Ans)C
51)What operation is supported in constant time by the doubly linked list, but not by the
singly linked list?
(a) Advance
(b) Move back
(c) First
(d) Retrieve
(e) All of the above are always constant time
Ans)B, Doubly linked list has two pointers pointing to forward and backward
Simultaneously
52) Consider the following statements.
(i) A linked list consists of a series of structures, which are necessarily adjacent in
memory.
(ii) In a singly linked list, each structure contains an element and a reference to a record
containing its successor.
(iii) In an array-based list, even if the array is dynamically allocated, an estimate of the
maximum size of the list is required.
(iv) In an array based list, inserting at position 0 requires first pushing the entire array
down one spot to make room.
(v) In an array-based list, deleting elements from the middle can be performed without
shifting the remaining elements.
Which of the above statements is/are valid for a list?
a. (ii) & (iv) only
b. (ii), (iii) & (iv) only
c. (iii), (iv) & (v) only
d. (ii) & (iv) only
e. (ii), (iii), (iv) & (v) only
Ans) B
53)Consider the following operations.
a. only middle
b. only first
c. only last
d. All
Ans)D
2. In Circular Doubly Linked List a node contain how many fields.
a. 1
b. 3
c. 2
d. None
Ans)B
3. Next pointer of last node in a circular linked list contains the address of.
a. Last node
b. Previous node
c. First Node
d. NULL
Ans)C
4. A linked list is called a circular list if
a. There is a loop in a linked list
b. If the last node contains a null pointer
c. If the last node contains the pointer to the first node
d. All
Ans : c
5. Null pointer represents
a. Empty stack
b. Empty queue
c. Empty circular list
d. Empty tree
Ans : c
6. A linked list is called a circular list if
e. There is a loop in a linked list
f. If the last node contains a null pointer
g. If the last node contains the pointer to the first node
h. All
Ans : c
Null pointer represents
e. Empty stack
f. Empty queue
g. Empty circular list
h. Empty tree
Ans : c
b. 2 and 3
c. 1 and 3
d. All
Ans)B
3.
x
Newnode
Which of the following correctly describes the steps in inserting element x immediately
after the element a in the above doubly linked list?
(a) Newnode = new DoublyLinkedListNode(x)
Newnode.element = x;
Newnode.next = Current.next;
Current.next = Newnode ;
(b) Newnode = new DoublyLInkedListNode(x) ;
Current = NewNode
Newnode.prev = Current
Newnode.next= Current.next
Newnode.rev.next = Newnode;
Newnode.next.prev = Newnode ;
(c) NewNode = new DoublyLinkedListNode(x) ;
Current = NewNode
Newnode.prev = Current;
Newnode.next = Current.next;
Newnode.next.prev = Newnode ;
Newnode.prev.next = Newnode ;
B
Tail
If the list is circular, and empty, which of the following statement(s) is/are valid?
Note: each node has two references such as next and previous.
(a) Head.next=null
(b) Tail.previous=Head
(c) Head.next=Tail
(d) Tail=Head
(e) Tail.next=null
Ans : b,c
4. Consider the following doubly linked list and its data structure.
Class Listnode
{
Object element;
Listnode next;
Listnode prev;
}
What would be the correct statement(s), when the doubly linked list is empty?
(a) Head.next=tail
(b) Current.next=tail
(c) Current.prev=Head
(d) Tail.prev=Head
(e) Current=nill
Ans : a, d
5) Consider the following doubly linked list and its data structure.
Class Listnode
{
Object element;
Listnode next;
Listnode prev;
}
Which of the following correctly describe(s) the steps to delete element b from the above
doubly linked
list?
(a) Current.next.next.prev=Current.prev
Current.next = Current.next.next
(b) Current.next = Current.prev.next
Current.next.next.prev=Current.prev
(c)Current.next=Current.next.next
Current.next.next.prev=Current.next.prev
(d) Current.next=tail
Head.next=Current.next.prev
(e) Current = Current.next.next
Current.next.next.prev=Current.prev
Ans : c
6) Consider the following doubly linked list and its data structure.
Class Listnode
{
Object element;
Listnode next;
Listnode prev;
}
Which of the following correctly describe(s) the steps in inserting elements x
immediately after the
element a in the above doubly linked list?
(a)current.next=x
x..prev=current
x.next=b
b.prev=x
(b) current.next=x
x..prev=current.prev
x.next=b
b.prev=x
(c) a.next=x
x..prev=current
x.next=b
b.prev=x
(d) Newnode.next= Current.next
Newnode.prev=Current
Newnode.prev.next=Newnode
Newnode.next.prev=Newnode
(e) Newnode.next= Current.next
Newnode.prev=Current.next.prev
Current.next=Newnode
Current.next.prev=Newnode
Ans : d, e
7) A set of basic list terms is given in Part A and some definitions are given in Part B as
follows.
Part A
(i) Circular linked list
(ii) Doubly linked list
(iii) Header node
(iv) Iterator class
(v) Sorted linked list
Part B
(p) A class that maintains a current position and performs all
routines which depend on knowing the position in the list.
(q) A linked list that allows bidirectional traversal by storing two
references per node.
(r) A list used to maintain items in a linked list in some
arrangement.
(s) An extra node in the linked list that holds no data but serves to
satisfy the requirement that every node has a previous node.
(t) A linked list in which the last cells reference points to the first.
Choose the best definition from Part B for the above five terms in Part A.
(a) (i).. (t) (ii)..(q) (iii)..(r) (iv)..(p) (v)..(s)
(b) (i).. (p) (ii)..(t) (iii)..(s) (iv)..(p) (v)..(r)
(c) (i).. (t) (ii)..(q) (iii)..(s) (iv)..(p) (v)..(r)
(d) (i).. (q) (ii)..(t) (iii)..(s) (iv)..(p) (v)..(r)
(e) (i).. (t) (ii)..(s) (iii)..(p) (iv)..(p) (v)..(r)
Ans : c
1.
Not a tree
A tree
A binary tree
A proper binary tree
A complete binary tree
A perfectly balanced binary tree
Ans. : e
2.
Not a tree
A tree
A binary tree
A proper binary tree
A complete binary tree
A perfectly balanced binary tree
Ans. : c
Not a tree
A tree
A binary tree
A proper binary tree
A complete binary tree
A perfectly balanced binary tree
Ans. : f
Not a tree
A tree
A binary tree
A proper binary tree
A complete binary tree
A perfectly balanced binary tree
Ans : d
B.
C.
D.
9. Which trees are heaps, with the heap ordering taken as <= on integers
a. A, B, C
b. A, C
c. A, C, D
d. B
Ans. : b
10. Which data structure has the fastest insertion procedure?
a. Binary search tree
b. Ordered array
c. Heap
d. Unordered linked list
e. Ordered linked list
Ans. : d
A.
B.
C.
D.
13. A Pre Order Traversing of Non empty Binary Tree is called as a _________
a. BFS
b. Depth-First Order
c. Linear
d. Sequential
Ans)B
14. The Non leaf nodes of a tree are also known as _____ nodes.
a. Internal
b. external
c. outer
d. root
Ans)A
15. A Binary Tree of height h, that contains exactly 2h-1 is called a __________
a. B tree
b. complete binary tree
c. Fully Binary Tree
d. AVL tree
Ans)c
16. A collection of one or more trees is _________.
a. Forest
b. Graph
c. complete binary tree
d. full binary tree
Ans)A
17. A balanced order-n multi way search tree in which each non-root node contains as
least (n-1)/2 keys is called as_______________.
a. B Tree
b. complete binary tree
c. full binary tree
d. AVL tree
Ans)A
18. Height of a Complete Binary Tree that contains n elements is _____
a. log(n*n)
b. log2(n+1)
c. log(n+1)
d. log(n)
Ans)B
19. A node that does not have any child nodes is called.
a. Empty
b. Root
c. Child
d. Leaf
Ans)D
20. A tree having larger data than root in right sub tree and smaller data in left sub tree
is called
a. Search Tree
b. Binary Tree
c. Complete Tree
d. AVL Tree
Ans)D
21. The drawing of every binary tree with n elements, n>0 has exactly how many
edges
a. n
b. 2n-1
c. n-1
d. n *log n
Ans)A
22.
33. Which of the following remarks about tree indexing are true?
1) It is efficient in dealing with strings of variable length
2) It is efficient if there are few member of data items
3) The number of disk accesses cant exceed the length of the particular string that is
searched
a. 1 and 2
b. 2 and 3
c. 1 and 3
d. All
Ans)C
34. In binary search tree which traversal is used for getting ascending order values
________.
a. Reverse order
b. Preorder
c. Postorder
d. Inorder
Ans)D
35. The numbers of null pointer are there in N number binary tree is ________.
a. N
b. N+1
c. N/2
d. N-1
Ans)B
36. The complexity of Binary search is ___________
a. O(log n*n)
b. O(log (n+1))
c. O(log n)
d. O(log n/2)
Ans)C
37. The number of different trees are possible with n nodes are_________
a. n-1
b. n+1
c. n
d. n/2
Ans)A
38. B-tree (failure nodes at same level) of nodes in k-ary tree of depth n is ______.
a. 1/n
b. 1/k
c. I+k
d. 1+n
Ans)B
39. AVL trees achieve the goal that search, insertion and deletion in a tree with n nodes
can all be achieved in the time that is _________
a. O(log n/2)
b. O(log (n+1))
c. O(log n*n)
d. O(log n)
Ans)D
40. Given a height balanced tree. If we add one more node, ________ nodes gets
unbalanced.
a. TWO
b. THREE
c. ONE
d. ZERO
Ans)B
41. Children of the same node are called
a. Leaves
b. branches
c. siblings
d. terminals
Ans)C
42. In a binary tree which traversal will print the elements in ascending order?
a. preorder
b. Postorder
c. Inorder
d. depends on data
Ans)C
43. A class which is used to traverse through the objects maintained by a container
class.
a. Protocol Class
b. maxin class
c. Concrete Class
d. Iterative Class
Ans)D
44. The header node in the link list sometime called as
1)base
2)anchor
3)footer
a. 1 and 2
b. 2 and 3
c. 1 and 3
d. None
Ans)A
45. what are the different traversal techniques available for trees
1)pre-order
2)postorder
3)inorder
a. 1 and 2
b. 2 and 3
c. 1 and 3
d. None
Ans)A
46. In an AVL tree, at what condition the balancing is to be done?
1)pivotal value greater than 1
2)pivotal value less than 1
3)pivotal value equal to 2
a. 1 and 2
b. 1 and 3
c. 2 and 3
d. All
Ans)D
47. Max or min tree i.e. also a complete binary tree known as
1)max heap
2)min heap
3)B+ tree
a. 1 and 2
b. 2 and 3
c. 1 and 3
d. None
Ans)A
48. A Full Binary Tree of height h contains exactly __________nodes
a. 2^(h+1)
b. 2^h-1
c. 2^(h-1)
d. 2h-1
Ans)D
49. The minimum balancing factor of an AVL tree is ______.
a. 0
b. -1
c. 1
d. -2
Ans)B
50. AVL trees achieve the goal that search, insertion and deletion in a tree with n nodes
can all be achieved in the time that is
a.
b.
c.
d.
Ans)D
O(log( n+1))
O(log n^2)
O(log n/2)
O(log n)
51. In between threaded binary tree and lexical ordered binary tree the process of
traversal is faster in __________ binary tree
a. Threaded
b. Lexial ordered
c. both are same
d. depends upon no. of nodes
Ans)B
52. A binary tree is a
a. A finite set of elements which is either empty or is partitioned into three
disjoint subsets,which are again binary trees in themselves
b. A finite set of elements which is either empty or is partitioned into three
disjoint subsets, which need not be a binary trees in themselves
c. A finite set of elements which is never empty and is partitioned into three
disjoint subsets, which are again binary trees in themselves
d. None
Ans : a
53. A node that has no child is called
a. father
b. Leaf
c. Ancestor
d. descendant
Ans : b
54. If A is the root of a binary tree and B is the root of its left or right sub tree, then B is
said to be, ____ of A
e. Left son
f. Right son
g. Both a and b
h. Either a or b
Ans : d
55. If A is the root of a binary tree and B is the root of its left or right sub tree, then A
is said to be, ____ of B
a. Left son
b. Right son
c. Father
d. 0
Ans : c
56. Node n1 is an ancestor of node n2
a. If n1 is the father of n2
b. If n1 is the father of some ancestor of n2
c. Both a and b
d. Either a or b
Ans : c
57. Node n2 is a descendant of n1
a. If n1 is the father of n2
b. If n1 is the father of some ancestor of n2
c. Both a and b
d. Either a or b
Ans : c
58. Two nodes are brothers if
a. They are the left sons
b. They are the descendents of the same node
c. They are not the leaf nodes
d. They are the left and right sons of the same father
Ans : d
59. The tree is said to be strictly binary tree if
a. Every level except possibly the deepest, in that binary tree is completely
filled
b. Every non leaf node in a binary tree has nonempty left and right subtrees
c. If in that binary tree each node has exactly zero or two children
d. A binary tree where every nodes left subtree has keys less than the node's
Key, and every right subtree has keys greater than the node's key
e. If it has leaves on more than one level
Ans : b,c
60. which of the following statement is true
a. Root of the tree has a level 0
b. The level of any node is one more than the level of its father
c. The depth of binary tree is the maximum level of any leaf in the tree
d. All the above
Ans : d
61. A Complete binary tree is,
a. A strictly binary tree
b. A strictly binary tree with all the leaves having their level equal to depth
c. Both a and b
d. None
Ans : b
62. If a binary tree contains m nodes at level L, then it contains atmost ____ nodes at
level L+1
a. 2^m
b. 2m
c. 2m+1
d. 2^m+1
Ans : b
63. The maximum number of nodes possible at level L is
a. 2^(L +1)
b. 2L
c. 2^L
d. 2^L+1
Ans : c
64. The total number of nodes in a complete binary tree of depth d is,
a. 2^(d+1)
b. 2^(d+1)-1
c. 2^(d+1)+1
d. None
Ans : b
65. A binary tree of depth d is an almost complete binary tree, if it satisfies
a. Any node at level less than d-1 has two sons
b. Any node n1 in the tree with a right descendent at level d, n1 must have a
left son and every left descendent of n1 is either a leaf at level d or has two
sons
c. Both a and b
d. None
Ans : c
66. Preorder is also known as
a. Root-First order
b. Symmetric order
c. Depth first order
d. None
Ans : c
67. Inorder is also known as
a. Root-First order
b. Symmetric order
c. Depth first order
d. None
Ans : b
68. What is the correct order, to traverse a non empty binary tree in preorder
1. Traverse the left subtree in preorder
3. Traverse the right subtree in
preorder
a. 1, 2, 3
b. 2, 3, 1
c. 2, 1, 3
d. 3, 2, 1
Ans : c
69. What is the correct order, to traverse a non empty binary tree in inorder
1. Traverse the left subtree in inorder 2. Visit the root 3. Traverse the right
subtree in inorder
a. 1, 2, 3
b. 2, 3, 1
c. 2, 1, 3
d. 3, 2, 1
Ans : a
70. What is the correct order, to traverse a non empty binary tree in preorder
1. Traverse the left subtree in postorder 2. Visit the root 3. Traverse the
right subtree in postorder
a. 1, 2, 3
b. 2, 3, 1
c. 1, 3, 2
d. 3, 2, 1
Ans : c
71. All the elements in the left subtree of a node n are less than the contents of n, and
all elements in the right subtree of a node n are less than the contents of n. Binary
tree with this property is called
a. Complete binary tree
b. Binary search tree
c. Ordered binary tree
d. Strictly binary tree
Ans : b, A binary tree where every nodes left subtree has keys less than the
node's key, and every right subtree has keys greater than the node's key.
72. Which traversal does not use a stack?
a. inorder
b. level order
c. postorder
d. preorder
e. all of these traversals uses a stack
Ans : b, Inorder, preorder, postorder traversal makes use of stack for implementing
14
/ \
2
11
/ \
/ \
1 3 10 30
/ /
7
40
Fig 1.1
73.
2
4
8
9
Ans : b
74. How many of the nodes have at least one sibling,in the tree of fig 1.1?
a.
b.
c.
d.
5
6
7
9
Ans : a
75. What is the value stored in the parent node of the node containing 30, in the tree of
fig 1.1?
a.
b.
c.
d.
10
11
14
None of the above
Ans : b
76.
How many descendants does the root have, in the tree of fig 1.1?
a.
b.
c.
d.
0
2
4
8
Ans : d
77.
2
3
4
8
Ans : b
78.
How many children does the root have, in the tree of fig 1.1?
a.
b.
c.
d.
2
4
6
8
Ans : a
79.
Ans : a
80.
What is the minimum number of nodes in a full binary tree with depth 3?
a.
b.
c.
d.
e.
3
4
8
7
15
Ans : d, A binary tree in which each node has exactly zero or two children is called a
Full binary tree.
81.
What is the minimum number of nodes in a complete binary tree with depth 3?
a.
b.
c.
d.
3
4
11
15
Ans : d, A complete binary tree is a binary tree in which every level, except possibly
the deepest, is completely filled.
82.
Which traversal computes the total size of each directory in the UNIX file
system?
a. inorder
b. level order
c. postorder
d. preorder
e. two or more of the above traversals could be used
Ans : c,
83.
Ans : b, every non-leaf node in a complete binary tree will have either 0 or 2
84.
a.
b.
c.
d.
0
3
4
5
b. data[i+2]
c. data[2*i + 1]
d. data[2*i + 2]
Ans : d
87.
2^d -1
2^(d+1)- 1
2^(d+1) + 1
2^(d+1)
Ans : b
88. For a strictly binary tree with n leaves, and level(i) for i between 1 and n equal the
level of the ith leaf is
a.
b.
c.
d.
ni=0
ni=1
n0=1
n1=1,
2n+1
2n-1
2n
None
b. level order
c. postorder
d. preorder
e. none of the above
Ans : d
92. Suppose that a binary tree includes 7 animals. What is the minimum number of
NONLEAF nodes in the tree?
a.
b.
c.
d.
e.
1
3
5
7
8
Ans : b
Fig 1.2
93.
fig1.2?
14
/ \
2
11
/ \
/ \
1 3 10 30
/ /
7
40
What is the order of nodes visited using a pre-order traversal, in the tree in
a.
b.
c.
d.
1 2 3 7 10 11 14
1 2 3 14 7 10 11
1 3 2 7 10 40 30
14 2 1 3 11 10 7
30
40
11
30
40
30
14
40
Ans : d
94.
fig1.2?
What is the order of nodes visited using an in-order traversal, in the tree in
a.
b.
c.
d.
1 2 3 7 10 11 14
1 2 3 14 7 10 11
1 3 2 7 10 40 30
14 2 1 3 11 10 7
Ans : b
30
40
11
30
40
30
14
40
95.
fig1.2?
What is the order of nodes visited using post-order traversal, in the tree of
a.
b.
c.
d.
1 2 3 7 10 11 14
1 2 3 14 7 10 11
1 3 2 7 10 40 30
14 2 1 3 11 10 7
30
40
11
30
40
30
14
40
Ans : c
96.
Consider this binary search tree: Suppose we remove the root,replacing it with
something from the left subtree. that will be the new root? (preserving the
subsets of the left and right subtrees)
14
/ \
2 16
/\
1 5
/
4
a.
b.
c.
d.
1
2
4
5
Ans : d
97.
Fig 1.3
a.
b.
c.
The inorder D H B E A F C I G J
The postorder H D E B F I J G C A
The preorder A B D H C E F G I J
d.
e.
f.
g.
The postorder H D E F B I J G C A
The inorder D H B E A F C G I J
The preorder A B D H E C F G I J
The postorder H D E B G I J F C A
Ans : a, b, f
98.
Consider the node of a complete binary tree whose value is stored in data[i] for
an array implementation. If this node has a left child, where will the left child's value be
stored?
a.
b.
c.
d.
data[i+1]
data[i+2]
data[2*i + 1]
data[2*i + 2]
Ans : c
99. Traversing a binary expression trees in preorder yields _____ form of expression
a.
b.
c.
d.
prefix
postfix
infix
none
$
/
\
/
\
+
*
/ \
/ \
A
*
+ C
/ \ / \
B C A B
Fig 1.3
a.
b.
c.
d.
ABC*+ABC*+$
AB+*CAB+*C$
ABC*+AB+C*$
ABCABC+*+*$
106.The preorder traversing of the tree gives the expression ABCEIFJDGHKL. What
is the postorder expression
a. ICEBJFKDGLHA
b. FJEILKGCBDHA
c. EICFJBGDKHLA
d. IEJFCGKLHDBA
Ans : d, Page no 240.Tenenbaum 1994 edition
107.The preorder traversing of the tree gives the expression ABDGCEHIF. What is
the Inorder expression
a. DBGHAEICF
b. DGBAHEICF
c. BGDEHACIF
d. DGABEHICF
Ans : b, Page no 240.Tenenbaum 1994 edition
108.The preorder traversing of the tree gives the expression ABDGCEHIF. What is
the postorder expression
a. GDBHIEFCA
b. GBDHIEFCA
c. GDBEIHCFA
d. GBDEIHCFA
Ans : a, Page no 240.Tenenbaum 1994 edition
109.The Inorder traversing of the tree gives the expression DGBAHEICF. What is the
postorder expression
a. GBDHIEFCA
b. GDBEIHCFA
c. GDBHIEFCA
d. GBDEIHCFA
Ans : c, Page no 240.Tenenbaum 1994 edition
110.The Inorder traversing of the tree gives the expression DGBAHEICF. What is the
preorder expression
a. ADBCGHEFI
b. ABDGCEHIF
c. ABDCGHEIF
d. ADBGCEHFI
Ans : b, Page no 240.Tenenbaum 1994 edition
111.The Postorder traversing of the tree gives the expression GDBHIEFCA. What is
the preorder expression
a. ADBCGHEFI
b. ABDCGHEIF
c. ADBGCEHFI
d. ABDGCEHIF
Ans : d, Page no 240.Tenenbaum 1994 edition
112.The Postorder traversing of the tree gives the expression GDBHIEFCA. What is
the Inorder expression
a. DBGHAEICF
b. BGDEHACIF
c. DGBAHEICF
d. DGABEHICF
Ans : c, Page no 240.Tenenbaum 1994 edition
113.The Postorder traversing of the tree gives the expression IEJFCGKLHDBA.
What is the Inorder expression
a. ICEBJFKDGLHA
b. EICFJBGDKHLA
c. ECFIKDGBJLHA
d. EIFCBJDKGHLA
Ans : b, Page no 240.Tenenbaum 1994 edition
114.The Postorder traversing of the tree gives the expression IEJFCGKLHDBA.
What is the Preorder expression
a. ABCIEFJDGKHL
b. ACBFIEJDGHKL
c. ABCEIFJDGHKL
d. ABCEIFDJGHLK
Ans : c, Page no 240.Tenenbaum 1994 edition
115.The Inorder traversing of the tree gives the expression EICFJBGDKHLA. What
is the postorder expression
a. ICEBJFKDGLHA
b. IEJFCGKLHDBA
c. FJEILKGCBDHA
d. EICFJBGDKHLA
Ans : b, Page no 240.Tenenbaum 1994 edition
116.The Inorder traversing of the tree gives the expression EICFJBGDKHLA. What
is the Preorder expression
a. ABCEIFJDGHKL
b. ABCIEFJDGKHL
c. ACBFIEJDGHKL
d. ABCEIFDJGHLK
Ans : a, Page no 240.Tenenbaum 1994 edition
117) Consider the following paragraph.
A tree is a data structure consisting of nodes connected to each other with references.
Each node in a tree may be connected to one or two nodes. Each node contains one or
more data fields and two references.
Which of the following is/are properly describing the above paragraph?
a. Multiway search Trees
b. Binary Trees
c. Binary Search Trees
d. General Trees
e. AVL trees
Ans) B
118)Consider the following rules.
Rule 1: For Loop: The running time of a for loop is at most the running time of the
statements inside the for loop (including test) times the number of iterations
Rule 2 : Nested Loop: The total running time of a statement inside a group of nested
loops is the running time of the statement multiplied by the product of the sizes of all the
loops.
Rule 3 : IF/ELSE : For the fragment
if( condition)
S1
else
S2
the running time of an if/else statement is never more than the running time of the test
plus the larger of the two numbers namely, the running time of S1 and that of S2.
Which of the following is a / are valid rule(s) in connection with analysis of algorithms?
a.
Rule 3 only
d. Rule 2 only
e. All
Ans) E
119) Consider the following four statements with blank positions.
If one finds a node with a/an . (i), he should stop the trace at that point.
Consider the node with imbalance and .(ii).. on the layers immediately
below this point on the path back to the new node.If these three nodes lie in a
(iii) apply a .(iv) rotation.If these three nodes lie in a dogleg pattern (bend in the path), apply (v). rotation to correct the imbalance.
The above sentences are in connection with insertion of new nodes in to an AVL tree.
Which of the following are correct words for the above blank positions?
a. (i)balance (ii)two nodes (iii) straight line (iv) single (v) double
b. (i)imbalance (ii)three nodes (iii) straight line (iv) single (v) double
c. (i)imbalance (ii)two nodes (iii) dog-leg (iv) single (v) double
d. (i)imbalance (ii)two nodes (iii) straight line (iv) double (v) single
e. (i)imbalance (ii)two nodes (iii) straight line (iv) single (v) double
Ans) E
120) Consider the following expression.
(A+B*C)$((A+B)*C)
Which of the following trees show(s) the equivalent expression tree for the above
expression? (Note: $ denotes power.)
Ans) C
121)
a.
AVL tree.
Binary Tree.
d. General Tree.
e.
Ans) B, C
123) In above fig, if one wants to insert a new node p=55, what is the correct insertion
point without violating the binary search property?
a. Right child of node number 18
b. Right child of node number 53
c. Left child of node number 63
d. Right child of node number 54
e. Left child of node number 54
Ans) D
124) In the above fig ,if one wants to insert a new node p= 84 after inserting the new
node p=55, to the above tree, what is the correct insertion point without violating the
binary search property?
a. Left child of node number 65
b. Left child of node number 63
c. Left child of node number 80
a.
Ans) C
(e)
None of these
Ans : e
3. Which of the following statements(s) describes a tree
(a) Each node in the binary tree can have at most 2 children.
(b) If every non leaf node in a binary tree has only one non empty left or right sub tree,
the tree is termed as a strictly B-tree.
(c) If number of levels is equal to 3, then total number of nodes equal to 15.
(d) A tree is an almost complete B-tree if and only if, each leaf in the tree is either last
level or level-1.
(e) Proper ancestor is defined as a node without itself.
Ans : a, e
4. What is the difference between Binary AVL trees and Balanced AVL trees?
(a) Each node in the Binary tree can have almost 2 sub-trees and each node in the
Balanced AVL tree can have many sub-trees.
(b) Binary Trees: Root value is always less than or equal to its left sub tree value and
greater than or equal to its right sub-tree value.
Balanced AVL Trees: Root value is always less than its left sub tree value and grater than
or equal to its right sub-tree value.
(c) Binary Trees:Balance factor must be 0.
Balanced AVL Trees:Balance factor should be 2,-1,0,+1 and +2
(d) Binary Trees:
Each node can have almost two sub-trees
Balanced ALV Trees: Each node can have almost two sub-trees, parent value always
less than or equal to its left sub tree values and grater than or equal to its right sub tree
values. Balance factor should be -1, 0, +1
(e) No suitable answer
Ans : e
5. Which of the following statement(s) is/are related to trees
(a) The total number of nodes in a tree is called its degree.
(b) Children of the same parent is said to be siblings
(c) The length of a path is one less than the no. of nodes in the path
(d) The height of a node in a tree is the length of the longest path from the node to leaf
(e) The depth of a tree is the maximum levels of any leaf in a tree
Ans : b, c, d, e
6. What would be the output if we enter the following data set (in the respective order)
into a standard program to construct a Binary search tree?
25, 72, 16, 11, 88, 26, 9, 36, 21, 45, 14, 69
(a)
25
16
72
11
36
21
14
88
26
45
25
(b)
16
11
21
26
88
14
69
72
36
45
69
25
(c)
16
72
11
21
26
88
36
14
69
45
(d)
21
16
25
11
72
14
88
36
26
45
(e)
25
72
69
26
36
16
11
25
14
45
Ans : b
7. Create a heap using a following set of integers 25,57,48,37,12,92,86. The final heap is
92
(a) .
37
12
86
25
48
57
92
(b)
37
12
86
25
57
48
(c) .
92
37
86
25
12
d)
48
57
92
86
57
(e)
12
25
92
48
57
86
25
57
12
57
48
Ans : c
8.
25
9
30
17
13
19
14
18
21
15
After deleting node number 17 of the above binary search tree, the resulting tree will be
(a) It is impossible to delete middle nodes in binary search tree
(b) Deleted node can be replaced by node number 19
(c) Deleted node can be replaced by node number 18
(d) Deleted node can be replaced by node number 15.
(i) 3 (ii) 0
(i) 3 (ii) 1
(i) 1 (ii) 2
(i) 0 (ii) 3
(i) 1 (ii) 1
Ans : b
10. Consider the following directed graph
B
C
A
0
0
0
0
0
B
0
0
0
0
0
C
0
0
0
0
0
D
1
1
1
1
0
E
1
1
1
0
1
A
B
C
D
E
A
0
0
0
0
0
B
0
0
0
0
0
C
1
1
0
0
0
D
1
1
1
1
1
E
1
1
1
1
1
(b)
(c)
A
B
C
D
E
A
0
0
0
0
0
B
0
0
0
0
0
C
1
1
0
0
0
D
0
1
1
1
1
E
1
1
1
1
1
A
B
C
D
E
0
0
0
0
0
A
1
1
1
1
1
B
1
0
0
0
1
C
1
1
1
1
1
D E
0
0
0
0
0
A
B
C
D
E
A
1
1
1
0
0
B
1
1
0
0
0
C
0
0
0
1
1
D
1
1
1
0
0
E
1
1
1
1
1
(d)
(e)
Ans : d
B
E
D
G
In order
Post order
(a) ABDGCEHIF,
(b) ABDGCEHIF,
(c) ABDGCEHIF,
(d) GDBAHECIF,
(e) ABDSCEHIF,
ADGBAHEICF,
DGBAHEICF,
DGBAHEICF,
DGBAHEICF,
DGBAHEICF,
AGDBHIEFC
GDBHIEFCA
GDBIHECFA
AGDBHIEFC
ASDBHIEFC
Ans : b
12. Which expression describes the pre-order traversal expression of the following
tree.
d
(a) (a+(b*c))+(((d*e)+f)*g)
(b) abc*+de*f+g*+
(c) ++a*bc*+*defg
(d) (a+b*c)+((d*e+f)*g)
(e) None of these
Ans : a
13. Consider the following tree.
A
C
B
F
E
I
H
L
J
M
C
D
E
G
H
J
(ii) E
(ii) E
(ii) E
(ii) E
(ii) E
Ans : c
17.Consider the following four (iv) statements:
(i) A binary tree can contain at most 2L nodes at level L.
(ii) A binary search tree node should have at least three data fields.
(iii) The balance factor of an AVL must have 1,0 or 1 at any node.
(iv) A tree must be a graph.
Which of the above is/are true?
(a) (i), (ii) and (iv) only
(b) (i), (ii) and (iii) only
(c) (i) and (iv) only
(d) (i), (iii) and (iv) only
(e) All of these
Ans :d
18.Consider the following sequence of six (vi) instructions:
(i) Insert a node in the same way as in an ordinary binary search tree.
(ii) Beginning with the new node, trace a path back towards the root, checking the
difference in height of the two subtrees at each node along the way.
(iii) If one finds a new node with an imbalance, the trace at this point is stopped.
(iv) Consider the node with the imbalance and the two nodes on the layers immediately
below this point on the path back to the new node.
(v) If these three nodes lie in a straight line, apply a single rotation to correct the
imbalance.
(vi) If these three nodes lie in a dog-leg pattern (that is, there is a bend in the path), apply
a double rotation to correct the imbalance.
What is the above pseudo code algorithm intended to do?
(a) Inserting a new node into an AVL tree.
(b) Deleting a node from an AVL tree.
(c) Structural modification of a heap.
(d) Elimination of imbalance of an AVL tree.
(e) Construction of an AVL tree.
Ans :a,e
A
D
Ans : b
20. {22,11,18,52,16,27,51,7} is a set of 8 integers.
If the binary search tree is created using the above set of integers, what will the resulting
tree be?
(a)
52
27
51
18
22
16
11
7
(b)
22
11
7
18
16
52
27
51
(c)
52
27
(d)
51
22
18
5216
27
51
16
11
11
18
22
7
(e)
22
11
52
18
07
27
51
16
Ans :b
21.Consider the following expression tree:
*
+
a
(a) ab+cd-*
(b) *+-abcd
(c)ab+*cd(d) (ab+)*(cd-)
(e) (a+b)*(c-d)
Ans :e
(ii)
25
21
17
12
75
78
17
18
19
23
(iii)
91
(iv)
30
75
45
16
14
80
45
18
28
24
48
46
30
48
32
Create a Binary search tree using the above set of integers. After deleting node number
65 of the above created binary search tree, the resulting tree(s) will be
(a)
30
12
49
17
51
22
30
(b)
70
56
12
49
68
17
56
22
70
51
68
(c)
30
49
12
51
68
17
70
56
22
30
(d)
49
12
68
17
22
70
51
56
(e)
70
56
68
51
49
Ans : b, d
70
17
12
22
27. Which of the following statement(s) is/are related to deleting nodes from a binary
search tree?
(a) The node to be deleted has no sons; the node can be deleted with very few
adjustments to the tree.
(b) The node to be deleted has no sons; the node can be deleted without any adjustment.
Delete the leaf node and set reference from its parent to null reference.
(c) The node to be deleted has two sub-trees. The method to be used is to replace the
node being deleted by the rightmost child of its left sub-tree.
(d) The node to be deleted has two sub-trees. The method to be used is to replace the
node being deleted by the leftmost child of its right sub-tree.
(e) The node to be deleted has one sub-tree; its only son can be moved up to take its
place.
Ans : b, c, d, e
28. Consider the following (iv) statements.
(i) A given B-tree is a multi-way search tree with a maximum of M branches at each
Node. The number M is called the order of the tree.
(ii) There is a single root node, which may have, as few as two children or none at all if
the root is the only node in the tree.
(iii) At all Nodes, except at the root and leaf nodes there must be at least half the
maximum number of children.
(iv) All leaves are on the same level.
Which one of the following is correct for the multi-way search trees?
(a) (i), (iii) only.
(b) (ii), (iii) only.
(c) (i), (ii), (iii) only.
(d) All of these.
(e) None of these.
Ans : d
29.Consider the two expression trees given below.
(i)
(ii)
*
4
-
+
3
What is the order of nodes of tree if traverse in the following sequence Pre-order, Inorder, Post-order?
(a) (i) + - 2 * 345, 234 * -5 +, 2-3 * 4 + 5
(ii) * - 23 + 45, 23 45 + *, 2-3 * 4 + 5
(b) (i) + - 2 * 345, 2 3 * 4 + 5, 234 * - 5 +
(ii) * - 23 + 45, 2 3 * 4 + 5, 23 45 + *
(c) (i) 234 * - 5 +, 2 3 * 4 + 5, + - 2 * 345
(ii) 23 45 + *, 2-3 * 4 + 5, * - 23 + 45
(d) (i) 3 * 4 2+5, 2 3 * 4 + 5, 234 * - 5 +
(ii) 23 45 + *, -*23 + 45, 2 3 * 4 + 5
(e) (i) -+ 2 * 345, 2 3 * 4 + 5, 234 * - 5 +
(ii) -* 23 + 45, 2 3 * 4 + 5, 23 45 + *
Ans : b
30.Consider the linked list given bellow.
2
10
31
12
29
13
25
20
If the above linked list is transformed into a binary search tree, the resulting tree will be
(a)
12
10
25
(d)
31
31
29
25
29
20
29
25
13
(c)
20
31
(b)
10
10
12
20
13
12
13
13
12
20
10
25
29
31
(e)
31
29
25
20
13
12
10
2
Ans : d
31. Consider the following pseudo code.
void PQR(Vertex v)
{ v.visited = true ;
For each w adjacent to v
if (!w.visited)
PQR(w); }
Which of the following is/are it intended to do?
(a) Finding the adjacency matrix.
(b) Depth first traversal.
(c) Finding the path matrix.
(d) Breadth first traversal.
(e) Calculating the shortest path.
Ans : b
32. Consider the following directed graph.
b
a
F
F
F
T
F
F
F
b
T
F
F
F
F
F
F
c
F
F
F
F
F
F
F
d
F
F
T
F
F
F
F
e
F
T
F
T
F
F
F
f
F
F
F
F
T
F
F
g
F
F
T
F
F
F
F
h
F
F
T
F
F
F
F
i
F
F
F
T
F
F
F
(b)
a
b
c
d
e
f
g
h
i
a
F
F
F
T
F
F
F
F
F
b
T
F
F
F
F
F
F
F
F
c
F
F
F
F
F
F
F
F
F
d
F
F
T
F
F
F
T
F
F
e
F
T
F
T
F
F
F
F
F
f
F
F
F
F
T
F
F
F
T
g
F
F
T
F
F
F
F
T
F
h
F
F
T
F
F
F
F
F
F
i
F
F
F
T
F
F
F
F
F
a
b
c
d
e
f
g
h
i
a
F
F
F
T
F
F
F
F
F
b
T
F
F
F
F
F
F
F
F
c
F
F
F
F
F
F
F
F
F
d
F
F
T
F
F
F
T
F
F
e
F
T
F
T
F
F
F
F
F
f
F
F
F
F
T
F
F
F
T
g
F
F
T
F
F
F
F
T
F
h
F
F
F
F
F
F
F
F
F
i
F
F
F
T
F
F
F
F
F
a
b
c
d
e
f
g
h
i
a
F
F
F
T
F
F
F
F
F
b
T
F
F
F
F
F
F
F
F
c
F
F
F
F
F
F
F
F
F
d
F
F
T
F
F
F
T
F
F
e
F
T
F
T
F
F
F
F
F
f
F
F
F
F
T
F
F
F
T
g
F
F
T
F
F
F
F
T
F
h
F
F
F
F
F
F
F
F
F
i
F
F
F
T
F
F
F
F
F
(c)
(d)
(e)
Ans : b
a
F
F
F
T
F
T
F
F
F
a
b
c
d
e
f
g
h
i
b
T
F
F
F
F
F
F
F
F
c
F
F
F
F
F
F
F
T
F
d
F
F
F
F
F
F
F
F
F
e
F
T
T
T
F
F
F
F
F
f
F
F
F
F
F
F
T
F
F
g
F
F
T
F
F
F
F
F
F
h
F
F
T
F
F
F
F
F
T
i
F
F
F
T
F
F
F
F
F
A
0
0
0
0
0
0
0
0
B C D
0 1 1
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
1 0 0
1 0 0
E F
0 0
1 1
0 0
0 0
0 0
0 0
0 1
1 1
G
0
0
1
0
0
1
0
1
H
1
1
1
0
0
1
1
1
A
B
C
D
E
F
G
H
A
0
0
0
0
0
0
0
0
B C D
1 1 1
1 0 0
1 0 0
0 0 0
0 0 0
1 0 0
1 0 0
1 0 0
E F
0 1
1 1
1 1
0 0
0 0
1 1
1 1
1 1
G
1
1
1
0
0
1
1
1
H
1
1
1
0
0
1
1
1
(b)
(c)
A
B
C
D
E
F
G
H
(d)
A
0
0
0
0
0
0
0
0
B C D
1 1 1
1 0 0
1 0 0
0 0 0
0 0 0
1 1 0
1 0 0
1 0 0
E F
1 1
1 1
1 1
0 0
0 0
1 1
1 1
1 1
G
1
1
1
0
0
1
1
1
A
B
C
D
E
F
G
H
A
0
0
0
0
0
0
0
0
B C D
1 1 1
1 0 0
1 0 0
0 0 0
0 0 0
1 0 0
1 0 0
1 0 0
E F
1 1
1 1
1 1
0 0
0 0
1 1
1 1
1 1
G
1
1
1
0
0
1
1
1
H
1
1
1
0
0
1
1
1
A
B
C
D
E
F
G
H
A
0
0
0
0
0
0
0
0
B C D
1 1 1
1 0 0
1 0 0
0 0 0
0 0 0
1 0 0
1 1 0
1 0 0
E F
1 1
1 1
1 1
0 0
0 0
1 1
1 1
1 1
G
1
1
1
0
0
1
1
1
H
1
1
1
0
0
1
1
1
H
1
1
1
0
0
1
1
1
(e)
Ans : d
34. We store n values in a data structure. Which of the data structures below
in decreasing order:
a) Left, parent, right
b) Parent, right, left
c) Parent, left, right
d) Right, left, parent
e) Right, parent, left
Ans : e
40. Consider the following tree :
A
B
If one represents the children at each node as a linked list tree node, what would be the
F
minimum E
number of references needed to store the above tree?
H
I
G
(a) 0
(b) 1
(c) 2
(d) 3
(e) Depends on the number of children in each node. 9) Consider the following program
segment:
Ans : c
41. Which of the following access methods and their definitions are not related and not
correct in connection with Binary trees?
(a) LeftChild(v ) :- Return the left child of v, an error condition occurs, if v is an
external node.
(b) LeftChild(v ) :- Return the left child of v, an error condition occurs, if v is an internal
node.
(c) Sibling(v) :- Return the sibling v, an error condition occurs, if v is the root.
(d) ) RightChild(v) :- Return the left child of v, an error condition occurs, if v is an
external node.
(e) RightChild(v) :- Return the right child of v, an error condition occurs, if v is an
external node.
Ans : b,d
42. Which of the following is/are not (an) AVL tree(s)?
10
(a)
b)
25
3
71
10
85
60
c)
17
12
16
25
d)
30
15
45
10
29
42
13
e)
45
30
20
80
42
Ans : b, c, d, e
43. Let T be a (proper) binary tree with n nodes, and let h denote the height of T.
Consider the following properties of T.
(i)The number of external nodes in T is at least h+1 and at most 2h
(ii)The number of internal nodes in T is at least h and at most 2h 1.
(iii) The total number of nodes in T is at least 2h+1 and at most 2h+1 1
Which of the above is valid in connection with (proper) binary trees?
(a) (i) only
(b) (i) and (ii) only
(c)(ii) and (iii) only
(d) (iii) only
(e) All of these
Ans : e
44.
If node u is the parent of node v, then we say that v is a ..(i)... of u. Two nodes
which are children of the same parent are (ii).. A node is (iii)if it has
no children and it is (iv),if it has one or more children. (v)
nodes are known as leaves.
Correct answers for the blank positions are
(a) (i) child (ii) siblings (iii) internal (iv) external
(b) (i) parent (ii) siblings (iii) external (iv) internal
(c) (i) child (ii) siblings (iii) external (iv) internal
(d) (i) child (ii) brothers(iii) external (iv) internal
(e) (i) child (ii) siblings (iii) internal (iv) internal
Ans : c,d
(v) internal
(v) external
(v) external
(v) external
(v) external
45.
+
*
+
a
b
c
d
Which of the following expressions shows the post order traversal of the above tree?
(a) ++a*bc*+*defg
(b) abc*+de*f+g+*
(c)abc*+de*f+g*+
(d) ++a*bc**+defg
(e) ab*c+de*f+g*+
Ans : c
46. Consider the following statements:
(i) In a max heap, root value is always higher than its children (if any).
(ii) Priority queues can be implemented by a heap.
(iii) A heap is fully filled from level 1 to level last 1.
Fig 1.1
Consider the following five statements.
(i) It is a tree.
(ii) It is a binary tree.
(iii) It is an AVL tree.
Which of the following is/are correct with respect to the above tree?
(a) Pre-order listing is ABCEIFJDGHKL.
(b) Pre-order listing is ABCIEFJDGHKL.
(c) In- order listing is EICFJBGDKHLA.
(d)In- order listing is EICFJBGKDHLA.
(e) Post-order listing is IEJFCGKLHDBA.
Ans : a, c, e
51.
The method one uses to replace the node being deleted by the rightmost node in its left
sub tree or
leftmost node in its right sub tree.
What does the above statement (algorithm segment) intend to do?
(a) Deleting a node from an AVL, if deleting node has both a left and a right child
(b) Deleting a node from a binary tree
(c) Deleting a node from a general tree
(d) Deleting a node from a binary search tree, if deleting node is a leaf node
(e) Deleting a node from a binary search tree, if deleting node has both a left and a right
Child
Ans : e
53. Consider the following table.
State on node
Effect of new node
Action of new state
(i) Balanced
Increase left sub tree height
Left-high
(ii) Balanced
Increase right sub tree height
Right-high
(iii)Left-high
Increase left sub tree height
Left balance
(iv)Right-high
Increase left sub tree height
Balanced
(v) Right-high
Increase right sub tree height
Left balance
Which of the above would be correct for inserting a new node into an AVL tree?
(a) (i) only
(b) (i) and (ii) only
(c) (i), (ii) and (iii) only
(d) (i) (ii) (iii) and (iv) only.
(e) (i) (iii) and (iv) only
Ans : d
54. Which of the following is/are correctly describing a step in the definition of the Heap
data structure?
(a) All leaves are on two adjacent levels.
(b) All leaves on the lowest level occur at the left of the tree.
(c) All leaves on the lowest level occur at the right of the tree.
(d) All levels above the lowest are completely filled.
(e) Balance factor is always -1,0,+1
Ans : a, b, d
55.
GRAPHS-01
1. What are the different traversal techniques available for Graphs
1)Depth-First Traversal
2)Pre-Order Traversal
3)Breadth-First Traversal
a. 2 and 3
b. 1 and 2
c. 1 and 3
d. All
Ans)C
2. A graph having 'n' number of arcs for
a node that have 'n' as the head is called its
1)Outdegree
2)Postdegree
3)predegree
a. 1 and 2
b. 1 and 3
c. 2 and 3
d. None
Ans)D
3. Which of the following statements is false?
o
o
o
o
Ans :D
4. Suppose you have a game with 5 coins in a row and each coin can be heads or
tails. What number of vertices might you expect to find in the state graph?
a. A. 7
b. B. 10
c. C. 25
d. D. 32
Ans : B
5) Which of the following statements is/are true in connection with graphs?
(a) If few nodes are associated with a Di-Graph, array based implementation is more
useful than linked list implementation.
(b) If the graph contains n nodes, a total of n2 locations must be used in array based
implementation.
(c) If the graph is not weighted, the entire graph can de described using the Adjacency
matrix.
(d) Wars halls Algorithm increases the efficiency of finding the transitive closure.
(e) An example of a real life situation that can be modeled by a graph is the Air path
System.
Ans) B, C, D, E
6) Which of the following statements is/are correct in connection with Graphs?
a. There are three kinds of Graphs, namely Directed Graphs, Un-directed Graphs
and Digraphs.
b. The In _degree of a node n is the number of arcs which have n as the head.
c. The path matrix of any Di-graph can be calculated as pathn[I][J]=adj1 [I][J] or
adj2[I][J] or adj3[I][J] or adjn[I][J]
d. Transitive closure can be calculated using the Path Matrix.
e. Transitive closure can be calculated using the Adjacency Matrix.
Ans) B, C, E
GRAPHS-02
1) A Graph consists of a set of
a. Lines
b. Nodes
c. Arcs
d. Figures
Ans) B,C
2) The second node in the ordered pair of nodes making up an arc is represented by
a. Head of the arrow
b. Beginning of the line
c. End of the line
d. Tail of the arrow
Ans) A
7) A cycle is
a. A path which starts and end into itself
b. A path which starts and end into the nearest node
c. A path which starts and end into the farthest node
d. A path which starts and end into any other node
Ans) A
9) In the ordered pair of nodes making up an arc, the head of the arrow represents
a. The first node
b. The second node
c. The nearest node
d. Siblings
Ans) B
13) A digraph is
a. A graph with ordered pairs of arcs that make up the nodes
b. A graph which is cyclic
c. A graph in which pair of nodes that make up the arcs are ordered pairs
d. A graph which is not cyclic
Ans) C
15) The _______ of a node N is the number of arcs that have N as the tail.
a. In degree
b. Out degree
c. Adjacent
d. Degree
Ans) B
16) Weight of an arc is
a. The number of arcs terminating at the nearest node.
b. The number of arcs starting at the nearest node.
c. The number associated with the arc
d. The number of nodes it connects.
Ans) C
17) The function ____ adds a node with information field to a graph and returns a pointer
to that node.
a. Addnode
b. Add
c. Getnode
d. adder
Ans) A
20) The _______represents the first node in the ordered pair of nodes making up an arc.
a. Tail of the arrow
b. End of the line
c. Head of the arrow
d. Beginning of the line
Ans) A
24) A forest may be defined as an acyclic graph in which every node has one or no
____________.
a. Predecessors
b. Adjacent nodes
c. Successors
d. Connections
Ans) A
25) An ordered pair of nodes make up the arcs, what is the graph called?
a. Digraph
b. Cyclic graph
c. Weighted graph
d. Directed graph
Ans) A, D
26) An unordered pair is indicated by
a. { }
b. [ ]
c. ( )
d. < >
Ans) A
27) The _______ of a node N is the number of arcs that have N as the head.
a. In degree
b. Out degree
c. Adjacent
d. Degree
Ans) A
32) In the ordered pair of nodes making up an arc, the tail of the arrow represents
a. The first node
b. The second node
c. The nearest node
d. Siblings
Ans) A
39) The In degree of a node N is the number of arcs that have N as _______.
a. The head
b. The tail
c. Incident arc
d. Outgoing arcs
Ans)A
43) The _______represents the second node in the ordered pair of nodes making up an
arc.
a. Tail of the arrow
b. Head of the arrow
c. Beginning of the line
d. End of the line
Ans) B
47) A____________, also called a bigraph, is a set of graph vertices decomposed into
two disjoint sets such that no two graph vertices within the same set are adjacent.
a. Concyclic graph
b. An acyclic graph
c. Bipartite graph
d. Network
Ans) C
Ans) A
50) The first node in the ordered pair of nodes making up an arc is represented by
a. Head of the arrow
b. Beginning of the line
c. End of the line
d. Tail of the arrow
Ans) D
51) Mark the statement(s) that are false
a. Arcs need not have any nodes associated with it
b. A node must have arcs associated with it.
c. A node need not have any arcs associated with it
d. A node does not have any arcs associated with it
Ans ) A,B,D
52) A number may be associated with each arc of the graph, such a graph
is called
a. Weighted graph
b. Numbered graph
c. Linked graph
d. Associated graph
Ans) A
a. Header node
b. Arc node
c. Allocated node
d. Graph node
Ans) C
60) A tree maybe defined as a forest in which only a single node has no_____________.
a. Predecessors
b. Adjacent nodes
c. Successors
d. Connections
Ans) A
61)
(a)
00110
00100
00010
00001
00010
(b)
00011
00011
00011
00010
10001
(c)
00011
10011
00011
00010
00001
(d) 0 0 0 1 1
00011
00001
00001
00010
(e)
00111
00111
00011
00011
00011
Ans : a
62. Which of the following condition(s) is/are correct for the graphs.
(i) A graph need not to be a tree
(ii) A tree must be a graph
(iii) A node need not have any arcs associated with it
(a) (i) only
(b) (i) and (iii) only
(c) (ii) and (iii) only
(d) (i) only
(e) None of these
Ans : e
63.
Find the depth first traversal order of the graph below starting at node 6.
1
0
5
6
2
4
3
(a) 6, 0, 1, 5, 4, 3, 2
(b) 6, 0, 4, 5, 1, 2, 3
(c) 6, 4, 5, 3, 2, 1, 0
(d) 6, 5, 4, 3, 2, 1, 0
(e) 6, 1, 2, 5, 4, 3, 0
Ans : a d e
64.
F
A
D
E
C
b
d
c
f
e
g
Which of the following is/are true about the adjacency list of the above graph?
a
b
c
gd
e
f
g
c, d, f
d, e
a, f
a, b, e, f
b, d
a, c, d
a
(a)
b.
(c)
a
(d)
a
b
c, d, f
d, e
a, f
a, b, e, f
b, d
a, c, d
c
d
e
f
g
(e)
a
b
c
d
e
f
g
e, d, f
d, c
a, f
a, b, e, f
d, b
a, c, d
Ans : a,d
67.Consider the following adjacency matrix:
A
B
C
D
E
A
T
F
T
T
T
B
F
F
F
F
T
C
T
F
F
T
F
D
T
F
T
F
F
E
T
T
F
F
F
Which of the following graph(s) is/are related to the above adjacency matrix?
(a)
A
D
C
E
(b)
A
D
C
E
(c)
A
D
C
E
(d)
A
D
C
E
(e)
A
Ans :d,e
68.
4
5
6
7
(b)
(c)
(d)
1
(e)
Ans :a
69.
3
What is/are the correct order(s) of nodes for the depth first traversal starting from node 0?
5
4
(a) 0-->1,-->2,-->3,-->6,-->4,-->5
(b) 0-->3,-->2,-->6,-->1,-->4,-->5
(c) 0-->3,-->6,-->2,-->1,-->4,-->5
(d) 0-->1,-->3,-->2,-->4,-->5,-->6
(e) 0-->1,-->2,-->3,-->6,-->5,-->4
Ans :a,b,c,e
70. Consider the following directed graph and the paragraph which follows:
2Km
B
A
3Km
5Km
4Km
D
8Km
(iv) ordered
(iv) ordered
(iv) directed
(iv) un-directed
(iv) directed
Ans :c,e
71.
A
Graph :G
E
Consider the following statements about the above directed-graph:(i) There are two
cyclic paths.(ii) There is only one path from node C to node B, where the path of length is
equal to 1.(iii) There is no direct path from Node A to itself.(iv) There are two paths from
node A to node B, where each path is of length equal to 2.Which of the above statements
is/are correct in relation to the above graph G?
(a) (i) and (iii) only
(b) (i) and (ii) only
(c) (i), (ii) and (iv) only
(d) (i), (ii) and (iii) only
(e) All of these
Ans :c
72.
E
D
a.
A
B
C
D
E
A
T
F
F
F
F
B
T
F
T
F
F
C
T
T
F
F
T
D
F
T
F
F
F
E
F
T
F
F
T
A
B
C
D
E
A
T
F
F
T
F
B
T
F
T
F
F
C
T
T
F
F
T
D
F
T
F
F
F
E
F
T
F
F
F
A
B
C
D
E
A
T
F
F
F
F
B
T
F
T
F
F
C
T
T
F
F
T
D
F
T
F
F
F
E
F
T
F
F
F
A
B
C
D
E
A
T
F
F
F
F
B
T
F
T
F
F
C
T
T
F
F
T
D
F
T
T
F
F
E
F
T
F
F
F
A
A T
B F
C F
B
T
F
T
C
T
F
F
D
F
T
T
E
F
T
F
b.
c.
d.
e.
D F F F F F
E F F T F F
Ans : e
73. Consider the following statements.
(i) A node n is incident to an arc x if n is one of the two nodes in the ordered pair of
nodes that comprise x.
(ii) The degree of a node is the number of arcs incident to it.
74.
V1
V2
V5
V4
V3
V6
V7
GRAPH 1.1
How many cylic paths are there in the above graph (GRAPH 1.1) starting from V3?
(a) 2
(b) 3
(c) 4
(d) 5
(e) More than 5
Ans : e
V1
V2
V3
V4
V5
V6
V7
V
1
0
0
1
0
0
0
0
V
2
1
0
0
0
0
0
0
V
3
0
0
0
1
1
1
0
V
4
0
1
0
0
1
0
0
V
5
0
1
0
0
0
0
0
V
6
0
0
0
1
0
0
1
V
7
0
0
0
1
1
0
1
V1
V2
V3
V4
V5
V6
V7
V
1
0
0
1
0
0
0
0
V
2
1
0
0
0
1
0
0
V
3
0
0
0
1
0
1
0
V
4
0
1
0
0
1
0
1
V
5
0
1
0
0
0
0
0
V
6
0
0
0
1
0
0
1
V
7
0
0
0
1
1
0
0
V1
V2
V3
V4
V5
V6
V7
V
1
0
0
1
0
0
0
0
V
2
1
0
0
0
0
0
0
V
3
0
0
0
1
0
1
0
V
4
0
1
0
0
1
0
0
V
5
0
1
0
0
0
0
0
V
6
0
0
0
1
0
0
1
V
7
0
0
0
1
1
0
0
V1
V2
V3
V4
V5
V6
V7
V
1
0
0
1
0
0
0
0
V
2
1
0
0
0
0
0
0
V
3
0
0
1
1
0
1
0
V
4
0
1
0
0
1
0
0
V
5
0
1
0
0
1
0
0
V
6
0
0
0
1
0
0
1
V
7
0
0
0
1
1
0
0
(b)
c)
d)
e)
V1
V2
V3
V4
V5
V6
V7
V
1
0
0
1
0
0
0
0
V
2
1
0
0
0
0
0
0
V
3
0
0
0
1
0
1
0
V
4
0
1
0
0
1
0
0
V
5
0
1
0
0
0
0
0
V
6
0
0
0
1
0
0
1
V
7
1
0
0
1
1
1
1
Ans : c
76) The Adjacency matrix of the GRAPH 1.1, when the path is of length 3 is:
(a)
V1
V2
V3
V4
V5
V6
V7
V
1
V
2
V
3
V
4
V
5
V
6
V
7
0
1
0
1
1
0
1
0
0
0
1
0
1
0
1
2
0
1
2
0
0
1
0
1
0
0
0
2
0
0
1
0
1
0
0
1
3
0
0
1
0
0
2
1
0
0
0
0
0
V
1
V
2
V
3
V
4
V
5
V
6
V
7
0
1
0
1
1
0
1
0
0
0
1
0
1
0
1
2
0
1
2
0
0
1
0
1
0
0
0
0
0
0
1
0
0
0
0
1
3
0
0
1
0
0
2
1
0
0
0
0
0
V
1
V
2
V
3
V
4
V
5
V
6
V
7
0
1
0
1
1
0
1
0
0
0
1
0
1
0
1
2
0
1
2
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
3
0
0
1
0
0
2
1
0
0
0
0
0
b)
V1
V2
V3
V4
V5
V6
V7
c)
V1
V2
V3
V4
V5
V6
V7
d)
V1
V2
V3
V4
V5
V6
V7
0
1
0
1
1
0
1
0
0
0
1
0
1
0
1
2
0
1
2
0
0
1
0
1
0
2
0
0
0
0
1
0
1
0
0
1
3
0
0
1
0
0
2
1
0
0
0
0
0
V
1
V
2
V
3
V
4
V
5
V
6
V
7
0
1
0
1
1
0
1
0
0
0
1
0
1
0
1
2
0
1
2
0
0
1
0
1
0
0
0
0
0
0
1
0
0
0
0
1
3
0
0
1
0
0
2
1
0
0
0
0
0
e)
V1
V2
V3
V4
V5
V6
V7
Ans : b, e
Graph
1
5
2
3
3
Fig 2
Fig 1
4
Which of the following statement(s) is/are correct in relation to the above two diagrams?
(a)Fig 2 represents the correct adjacency list node representation of Fig 1.
(b) In fig 2, shaded nodes are called their adjacency list node representations.
(c) In Fig 2, non-shaded nodes are called their arc representations.
(d) There is no relationship between Fig 1 & Fig 2.
(e) Fig 2 is incomplete with respect to Fig 1.
Ans : a, b, c
78) Consider the following paragraph.
The (i) .of a node is the number of incident arcs of it. The. (ii).. of a
node A is the number of arcs which have A as the head and the .(iii) of A is
the number of arcs which have A as the tail. A node A is said to be adjacent to a node B
if there is an arc connecting A and B . In the case of a directed graph, A is said to be a
.(iv).. of B if there is an outgoing arc from A to B
Correct words for the blank positions are:
(a) ) (i) degree
(b)( i) indegree
(c) ( i) degree
(d) ( i) degree
(e) (i) successor
(ii) indegree
(iii) outdegree
(ii) degree
(iii) outdegree
(ii) indegree
(iii) outdegree
(ii) outdegree (iii) indegree
(ii) indegree
(iii) outdegree
(iv) predecessor
(iv) successor
(iv) successor
(iv) successor
(iv) successor
Ans : a
79) Consider the following polynomial
aknk+ak-1nk-1+.a0 .
What is the Big O representation of the above polynomial?
(a) O(n)
(b) O(nk)
(c) O(nk+1)
(d) O(log k)
(e) O(nlog n)
Ans : b
80.Consider the following adjacency list table:
Node
A
B
Adjacency list
B,C,D
C
C
D
E
C,E
C
Which of the following graphs summarize(s) the above adjacency list table?
(a)
A
(b)
(c)
A
(d)
E
B
e)
Ans : a
81. {2,8,6,1,10,15,3,12,11} is a set of integers. If you create a maximum heap and store
it in an array, what would be the final values in the array?
(a)1,2,3,6,8,10,11,12,15
(b)15,12,11,10,8,6,3,2,1
(c) 15,12,6,11,10,2,3,8,1
(d) 15,12,6,10,11,2,3,1,8
(e)15,12,10,11,2,6,3,1,8
Ans : e
82. Which of the following statements is/are correct in connection with a graph?
(a) Purely array-based representation of a graph is called its path matrix.
(b) Graphs may be used as diagrams which illustrate the relationship between pairs of
elements in a set of objects.
(c) Depth first traversal and Breadth first traversal techniques can be used only for
graphs.
(d) A multi-graph is a graph where two vertices can be joined by multiple edges.
(e) A graph is called a weighted graph if each edge has an assigned number.
Ans : b, d, e
83. Consider the following directed graph.
.
Which of the following is/are not (an) output(s) of Depth first traversal?
(a) 0-->1-->2-->4-->5-->3
(b) 0-->1-->2-->5-->4-->3
(c) 0-->3-->1-->2-->4-->5
(d) 0-->1-->2-->2-->4-->3
(e) 0-->1-->2-->5-->4-->1
Ans : d, e
84. Which of the following is/are correct in connection with graph data structures?
(a) Path matrix can be defined as path [i][j] = adj[i][j] or adj2[i][j] or adj3i][j]
or.
(b) Transitive closure can be determined by using the path matrix.
(c) adj3[i][j]= adj2 [i][j]* adj[i][j] .
(d) Warshalls algorithm will increase the efficiency of finding the Transitive closure.
(e) Warshalls algorithm will increase the efficiency of finding the adjacency matrix.
Ans : a, c, d
85. Which of the following is/are not (an) alternative representation(s) of graphs?
(a) An adjacency list
(b) An adjacency matrix
(c) Depth first traversal
(d) Incidence matrix
(e) Breadth first traversal
Ans : c, e
HASHING
1) The function that transforms a key into a table index is called a _________
a. Hash function
b. Key function
c. Transformation function
d. Table function
Ans) A ,
Function that transforms key to table index is called hash function
2) One of the techniques of dealing with the hash collision is
a. Chaining
b. Addressing
c. Resolving
d. Probing
Ans) A
3) ________ builds a linked list of all items whose keys hash to the same values.
a. Chaining
b. Addressing
c. Resolving
d. Probing
Ans) A
4) Hashing allows direct access to the _______
a. Link
b. Tuple
c. Data
d. Table
Ans) D
5) One way to eliminate all clustering is
a. Quadratic rehash
b. Rehashing
c. Hashing
d. Double hashing
Ans) D
6) Mark the statement(s) that is/are true
a. Attempt made to insert a record K2 in the position where K1 is already placed
is defined as Hash collision
b. Transforming a key into a table index is called hash function
c. Attempt made to insert a record K2 in the position where K1 is already placed
is defined as Hash function
d. Transforming a key into a table index is called Hash collision
Ans) A, B
7) If the ________ of the item is found to be occupied during a search the rehash function
is again used to locate the item.
a. Proper position
b. Hash position
c. Search position
d. Key position
Ans) B
8) The larger the range of the hash functions the less likely it is that the two keys yield
the same _________.
a. Hash value.
b. Key value
c. Table value
d. Tuple value
Ans) A
9) Different keys that hash to the same value follow the same rehash path. This is called
a. Secondary clustering
b. Primary clustering
c. Double hashing
d. Quadratic rehash
Ans) A
10) __________ permits a hash table to expand and shrink dynamically
without requiring an index.
a. Linear hashing
b. Linear rehashing
c. Extendible hashing
d. Dynamic hashing
Ans) A
11) The function that transforms a key into a __________ is called a hash function.
a. Key index
b. Data table
c. Table index
d. Record
Ans) C
12) __________ involves using a secondary hash function on the hash key of the item.
a. Probing
b. Addressing
c. Resolving
d. Rehashing
Ans)D
13) All items whose keys hash to the same values is built into a linked list, this is called
a. Addressing
b. Resolving
c. Chaining
d. Probing
Ans) C
14) Two keys that hash into different values compete with each other in _________
is called primary clustering.
a. Hash table
b. Successive rehashes
c. Link table
d. Secondary hash
Ans) B
15) The _______of a hashing method is usually measured by the average number of table
positions that must be examined in searching for a particular item.
a. Accuracy
b. Efficiency
c. Complexity
d. Easiness
Ans) B
16) If r is the record whose key hashes into hr, hr is called
a. Function of r
b. Hash key of r.
c. Function key of r
d. Key of r
Ans) B
17) Rehashing involves using a secondary hash function on the __________ of the item.
a. Hash Key
b. Data Key
c. Table Key
d. Index Key
Ans) A
18) A good hash function is one that
a. Spreads the records uniformly throughout the table
b. Minimizes duplication
c. Reduces link fields
d. Reduces duplication
Ans) A,B
19) One way of eliminating _________is to allow the rehash function to depend on the
number of times that the function is applied to a particular hash value.
a. Secondary clustering
b. Primary clustering
c. Double hashing
d. Quadratic rehash
Ans) B
20) ________is defined as any hashing scheme in which any newly inserted element is
equally likely to be placed at any of the empty positions of the hash table.
a. Quadratic rehash
b. Double hashing
c. Uniform hashing
d. Rehashing
Ans) C
21) The function that transforms a ______ into a table index is called a hash function.
a. Key
b. Data
c. Table
d. Index
Ans) A
22) Hash collision can be dealt with techniques like
a. Resolving and addressing
b. Probing
c. Rehashing and chaining
d. Hashing
Ans) C
23) Chaining builds __________of all items whose keys hash to the same values
a. An index
b. A linked list
c. A collection
d. A grouping
Ans) B
24) The phenomenon, where two keys that hash into different values compete with each
other in successive rehashes is called _____________.
a. Double hashing
b. Quadratic rehash
c. Primary clustering
d. Secondary clustering
Ans) C
25) It is difficult to delete items from the hash table that uses ________for search and
insertion.
a. Rehashing
b. Addressing
c. Probing
d. Linking
Ans) A
26) If h is a hash and key is key______ is called the hash of key.
a. h-key
b. key(h)
c. h(k)
d. h(key)
Ans) D
27) Rehashing involves using a secondary ________ on the hash key of the item.
a. Hash function
b. Key function
c. Transformation function
d. Table function
Ans) A
28) A good hash function is one that minimizes ___________.
a. Collisions
b. Duplication
c. Creation
d. Link fields
Ans) A
29) Any __________ that depends solely on the index to be rehashed causes
primary clustering.
a. Rehash function
b. Key function
c. Hash function
d. Table function
Ans) A
30) The Efficiency of a hashing method is usually measured by the average number of
________ that must be examined in searching for a particular item.
a. Table positions
b. Tuple
c. Data
d. Links
Ans) A
31) Hash collision is defined as
a. An attempt made to insert a record K2 in the position where K1 is already placed
b. Transforming a key into a table index
c. Inserting an already existing record
d. Secondary
Ans) D
38) The chaining technique involves adding an extra_________ to each table position.
a. Series of data
b. Line
c. Tuple
d. Link field
Ans) D
39) Any rehash function that depends solely on the index to be rehashed causes
__________.
a. Double hashing
b. Quadratic rehash
c. Primary clustering
d. Secondary clustering
Ans) C
40) The Efficiency of a________ is usually measured by the average number of table
positions that must be examined in searching for a particular item
a. Rehash method
b. Linking method
c. Hashing method
d. Searching method
Ans) C
41) One of the techniques of dealing with the hash collision is
a. Probing
b. Addressing
c. Resolving
d. Rehashing
Ans) D
42) If the Hash function of the item is found to be occupied during a search the _______
is again used to locate the item.
a. Key function
b. Hash function
c. Transformation function
d. Rehash function
Ans) D
43) ___________ allows direct access to the table.
a. Probing
b. Rehashing
c. Hashing
d. Addressing
Ans) C
44) Secondary clustering is the phenomenon where different keys that hash to the same
value follow ___________
a. Different rehash path
b. Same rehash path
c. Selected path
d. Ideal path
Ans) B
45) Linear hashing permits a________ to expand and shrink dynamically
without requiring an index.
a. Index table
b. Hash table
c. Sorted list
d. Grouped elements
Ans) B
46) If an attempt is made to insert a record k2 in the position where k1 is already placed
The situation that results is called
a. Hash collision
b. Probing
c. Hash clash
d. Invalid insertion
Ans) A, C
47) The _________is applied successfully until an empty position is found where the
items can be inserted.
a. Key function
b. Hash function
c. Transformation function
d. Table function
Ans) B
48) The larger the range of the _________ the less likely it is that the two keys yield the
same hash value.
a. Key function
b. Hash function
c. Transformation function
d. Table function
Ans) B
49) One way of eliminating primary clustering is to allow the ________ to depend on the
number of times that the function is applied to a particular hash value.
a. Key function
b. Hash function
c. Table function
d. Rehash function
Ans) A
50) Uniform hashing is defined as any___________ in which any newly inserted element
is equally likely to be placed at any of the empty positions of the hash table
a. Sorting scheme
b. Hashing scheme
c. Searching scheme
d. Linking scheme
Ans) B
51) The following paragraph is connected with hashing:
The process of mapping large amounts of data into a smaller table is called (i) .
A good hash function should satisfy two criteria, namely quickness to compute and
minimisation of the number of (ii) . Minimization of (iii) can be
achieved by choosing a hash function that spreads the incoming data as evenly as
possible over the hash table.
Correct terms for the blanks positions are:
(a)
(b)
(c)
(d)
(e)
Ans :c