NEC licence exam preparation, made clearer.Practice questions, syllabus guides, and timed mocks for Nepal engineers.New study resources are added regularly.NEC licence exam preparation, made clearer.Practice questions, syllabus guides, and timed mocks for Nepal engineers.New study resources are added regularly.
Which of the following is a disadvantage of external sorting?
A.
It is not stable
B.
It requires more disk I/O than internal sorting
C.
It is not a comparison-based sorting algorithm
D.
It is only suitable for datasets with a small number of distinct values
·
Question 3
Which of the following sorting algorithms is based on the idea of selecting the smallest element in the unsorted part of an array and swapping it with the first element in the unsorted part of the array?
A.
Bubble sort
B.
Insertion sort
C.
Selection sort
D.
Quick sort
·
Question 4
Which of the following sorting algorithms is based on the idea of partitioning an array into two subarrays, with elements in the left subarray being smaller than the pivot and elements in the right subarray being larger than the pivot?
A.
Bubble sort
B.
Insertion sort
C.
Selection sort
D.
Quick sort
·
Question 5
In Insertion sort, which of the following is true about the sorted part of the array after the first iteration?
A.
The first element is always the smallest element in the array
B.
The first element is always the largest element in the array
C.
The first element is always in its correct sorted position
D.
The first element is always in its correct sorted position relative to the second element
·
Question 6
What is the time complexity of Insertion sort in the worst-case scenario?
A.
O(n)
B.
O(nlogn)
C.
O(n2)
D.
O(logn)
·
Question 7
In Selection sort, how many comparisons are made in the first iteration of the outer loop?
A.
n
B.
n−1
C.
n/2
D.
log(n)
·
Question 8
What is the time complexity of Selection sort in the best-case scenario?
A.
O(n)
B.
O(nlogn)
C.
O(n2)
D.
O(logn)
·
Question 9
Which of the following is an advantage of Insertion sort over Selection sort?
A.
It is faster for small datasets
B.
It requires fewer comparisons
C.
It has a better worst-case time complexity
D.
It is easier to implement
·
Question 10
Which of the following is an advantage of Selection sort over Insertion sort?
A.
It requires less memory
B.
It has a better worst-case time complexity
C.
It is stable
D.
It is more efficient for large datasets
·
Question 11
What is the time complexity of Insertion sort in the best-case scenario?
A.
O(n)
B.
O(nlogn)
C.
O(n2)
D.
O(logn)
·
Question 12
Which of the following is a disadvantage of Selection sort?
A.
It is not stable
B.
It requires more memory than Insertion sort
C.
It has a worse worst-case time complexity than Insertion sort
D.
It is difficult to implement
·
Question 13
What is Warshall's algorithm used for?
A.
To find the shortest path between two vertices in a graph
B.
To find the transitive closure of a graph
C.
To find the minimum spanning tree of a graph
D.
To find the maximum flow in a network
·
Question 14
Warshall's algorithm is based on which concept?
A.
Depth-first search
B.
Breadth-first search
C.
Matrix multiplication
D.
Greedy algorithm
·
Question 15
What is the time complexity of Warshall's algorithm?
A.
O(n2)
B.
O(nlogn)
C.
O(n3)
D.
O(2n)
·
Question 16
What is a priority queue?
A.
A queue with elements ordered based on their priority
B.
A queue with elements ordered based on their frequency of use
C.
A queue with elements ordered based on their age
D.
A queue with elements ordered randomly
·
Question 17
What is the main difference between a min heap and a max heap?
A.
Min heap has elements ordered in ascending order, while max heap has elements ordered in descending order
B.
Min heap has elements ordered in descending order, while max heap has elements ordered in ascending order
C.
Min heap is a complete binary tree, while max heap is not
D.
Min heap is not a complete binary tree, while max heap is
·
Question 18
What is the time complexity of inserting an element into a heap?
A.
O(n)
B.
O(logn)
C.
O(1)
D.
O(nlogn)
·
Question 19
What is the time complexity of deleting the minimum element from a min heap?
A.
O(n)
B.
O(logn)
C.
O(1)
D.
O(nlogn)
·
Question 20
What is the time complexity of heap sort?
A.
O(n)
B.
O(logn)
C.
O(nlogn)
D.
O(n2)
·
Question 21
What is topological sorting?
A.
A method for sorting nodes in a directed acyclic graph (DAG) in a linear order such that for every directed edge (u, v), vertex u comes before vertex v
B.
A method for finding the shortest path in a directed graph
C.
A method for finding the longest path in a directed graph
D.
A method for finding a cycle in a directed graph
·
Question 22
What is the main difference between depth-first topological sorting and breadth-first topological sorting?
A.
Depth-first topological sorting sorts nodes based on their depth, while breadth-first topological sorting sorts nodes based on their breadth
B.
Depth-first topological sorting sorts nodes based on their breadth, while breadth-first topological sorting sorts nodes based on their depth
C.
Depth-first topological sorting uses a stack, while breadth-first topological sorting uses a queue
D.
Depth-first topological sorting uses a queue, while breadth-first topological sorting uses a stack
·
Question 23
What is the time complexity of depth-first topological sorting?
A.
O(n)
B.
O(nlogn)
C.
O(n2)
D.
O(2n)
·
Question 24
What is the time complexity of breadth-first topological sorting?
A.
O(n)
B.
O(nlogn)
C.
O(n2)
D.
O(2n)
·
Question 25
What is the main operation performed on a linear queue?
A.
Insertion
B.
Deletion
C.
Both A and B
D.
Sorting
·
Question 26
What is the main advantage of using a circular queue over a linear queue?
A.
Avoids overflow issues
B.
Easy implementation
C.
Faster than linear queue
D.
Better memory utilization
·
Question 27
What is the time complexity of inserting an element into a circular queue?
A.
O(1)
B.
O(logn)
C.
O(n)
D.
O(nlogn)
·
Question 28
What is the time complexity of deleting an element from a circular queue?
A.
O(1)
B.
O(logn)
C.
O(n)
D.
O(nlogn)
·
Question 29
What is the main difference between linear queue and circular queue in terms of handling overflow?
A.
Linear queue handles overflow by increasing its size dynamically, while circular queue handles overflow by making the front and rear pointers point to the first position
B.
Linear queue handles overflow by making the front and rear pointers point to the first position, while circular queue handles overflow by increasing its size dynamically
C.
Linear queue handles overflow by using a linked list, while circular queue handles overflow by making the front and rear pointers point to the first position
D.
Linear queue handles overflow by making the front and rear pointers point to the first position, while circular queue handles overflow by using a linked list
·
Question 30
What is the basic syntax for checking if a stack is full in C?
A.
`if(top == MAX_SIZE-1)`
B.
`if(top >= MAX_SIZE)`
C.
`if(top == MAX_SIZE)`
D.
`if(top > MAX_SIZE-1)`
·
Question 31
What is the basic syntax for checking if a stack is empty in C?
A.
`if(top == -1)`
B.
`if(top <= -1)`
C.
`if(top == 0)`
D.
`if(top < 0)`
·
Question 32
What is the basic syntax for handling overflow in a stack in C?
A.
`printf("Stack overflow\n");`
B.
`return -1;`
C.
`exit(1);`
D.
Throw an exception
·
Question 33
What is the basic syntax for handling underflow in a stack in C?
A.
`printf("Stack underflow\n");`
B.
`return -1;`
C.
`exit(1);`
D.
Throw an exception
·
Question 34
What is the basic syntax for checking if a queue is full in C?
A.
`if(rear == MAX_SIZE-1)`
B.
`if(rear >= MAX_SIZE)`
C.
`if(rear == MAX_SIZE)`
D.
`if(rear > MAX_SIZE-1)`
·
Question 35
What is the basic syntax for checking if a queue is empty in C?
A.
`if(front == rear)`
B.
`if(front > rear)`
C.
`if(front >= rear)`
D.
`if(front == -1)`
·
Question 36
What is the basic syntax for handling overflow in a queue in C?
A.
`printf("Queue overflow\n");`
B.
`return -1;`
C.
`exit(1);`
D.
Throw an exception
·
Question 37
What is the basic syntax for handling underflow in a queue in C?
A.
`printf("Queue underflow\n");`
B.
`return -1;`
C.
`exit(1);`
D.
Throw an exception
·
Question 38
What is the basic syntax for checking if a circular queue is full in C?
A.
`if((rear+1)%MAX_SIZE == front)`
B.
`if(rear == front)`
C.
`if(rear == MAX_SIZE-1)`
D.
`if(rear >= MAX_SIZE)`
·
Question 39
What is the basic syntax for checking if a circular queue is empty in C?
A.
`if(front == rear)`
B.
`if(front > rear)`
C.
`if(front >= rear)`
D.
`if(front == -1)`
·
Question 40
What is the basic syntax for handling overflow in a circular queue in C?
A.
`printf("Circular queue overflow\n");`
B.
`return -1;`
C.
`exit(1);`
D.
Throw an exception
·
Question 41
What is the basic syntax for handling underflow in a circular queue in C?
A.
`printf("Circular queue underflow\n");`
B.
`return -1;`
C.
`exit(1);`
D.
Throw an exception
·
Question 42
What is the balancing factor of a node in an AVL tree?
A.
The difference in height between the left and right subtrees of the node
B.
The sum of the heights of the left and right subtrees of the node
C.
The height of the node's parent
D.
The number of children the node has
·
Question 43
What is the range of the balancing factor in an AVL tree?
A.
−1 to 1
B.
−2 to 2
C.
−3 to 3
D.
0 to 2
·
Question 44
What does a balancing factor of −1 indicate in an AVL tree?
A.
The left subtree is taller than the right subtree
B.
The right subtree is taller than the left subtree
C.
The left and right subtrees are equal in height
D.
The node is a leaf node
·
Question 45
What does a balancing factor of 0 indicate in an AVL tree?
A.
The left and right subtrees are equal in height
B.
The left subtree is taller than the right subtree
C.
The right subtree is taller than the left subtree
D.
The node is a leaf node
·
Question 46
What does a balancing factor of 2 indicate in an AVL tree?
A.
The left subtree is taller than the right subtree by 2 levels
B.
The right subtree is taller than the left subtree by 2 levels
C.
The left subtree is taller than the right subtree by 1 level
D.
The right subtree is taller than the left subtree by 1 level
·
Question 47
What is the maximum possible height difference between the left and right subtrees of a node in an AVL tree?
A.
1 level
B.
2 levels
C.
3 levels
D.
4 levels
·
Question 48
How is the balancing factor used to maintain balance in an AVL tree?
A.
Whenever a node is inserted or deleted, the balancing factors of all nodes in the affected subtree are updated, and if any node has a balancing factor outside the range of −1 to 1, rotations are performed to rebalance the tree.
B.
Whenever a node is inserted or deleted, the balancing factors of all nodes in the tree are updated, and if any node has a balancing factor outside the range of −2 to 2, rotations are performed to rebalance the tree.
C.
Whenever a node is inserted or deleted, the balancing factors of all nodes in the affected subtree are updated, and if any node has a balancing factor outside the range of 0 to 2, rotations are performed to rebalance the tree.
D.
The balancing factor is not used to maintain balance in an AVL tree.
·
Question 49
What is the correct postfix notation for the infix expression 3+4∗2/(1−5)∧2∧3?
A.
342∗15−23∧/+
B.
342∗15−32∧/+
C.
342∗15−2∧3∧/+
D.
342∗15−23∧/+
·
Question 50
What is the correct infix notation for the prefix expression ∗+3/21−5∧23?