0% found this document useful (0 votes)
278 views

Cse357 MCQ

Uploaded by

sharma32511.ps
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
278 views

Cse357 MCQ

Uploaded by

sharma32511.ps
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

CSE357

How many child processes will be created if fork() called 3


times consecutively

options -

a. 8

b. 7

c. 9

d. 6

If in a virtual memory management scheme page offset is


of 10-bits and total pages are 1024 what will be the length
of the virtual address ?
(a) 10 bits
(b) 15 bits
(c) 20 bits
(d) data insufficient

An operating system designed for applications with


specific timing requirements is
(a) Time-Sharing Operating System
(b) Multiprogramming Operating System
(c) Multitasking Operating System
(d) Real-Time Operating System
A type of kernel that incorporates all essential operating
system functions and services into a single, large
executable program is
(a) Monolithic Kernel
(b) Microkernel
(c) Exokernel
(d) Nanokernel

A process that has completed execution but still has an


entry in the process table is
(a) Daemon Process
(b) Orphan Process
(c) Zombie Process
(d) Critical Process

Which of the following is disadvantage of Priority


Scheduling
(a) Starvation
(b) convoy effect
(c) difficult to predict burst times accurately
(d) All of the above

Threads that share resources and require less overhead to


create and manage
(a) light weight
(b) heavy weight
(c) shared
(d) user type

Mechanism employed in operating systems to control the


access to shared resources by multiple processes or
threads is
(a) Semaphore
(b) Synchronization
(c) Critical section
(d) None of the above

Q(9) Mutex is a
(a) counter
(b) binary state
(c) both state and counter
(d) neither state nor counter

Q(10) What else is a command interpreter called?


(a) prompt
(b) kernel
(c) shell
(d) command

Q(11) RIP( Routing Information Protocol ) uses which routing


algorithm ?
(a) Link state routing
(b) Distance Vector routing
(c) path Vector routing
(d) Random routing

Q(12) Which of the following is NOT a common type of


computer network?
(a) PAN (Personal Area Network)
(b) WAN (Wide Area Network)
(c) SAN (Storage Area Network)
(d) LAN (Local Access Network)

(13) In networking terminologies, what are signals?


(a) Physical media used for data transmission
(c) Binary-encoded data packets
(0) Electrical or electromagnetic representations of data
(d) Network protocols for data exchange

(14) Which network topology connects each device to a


central hub or switch?
(c) Star
(a) Ring
(b) Bus
(d) Mesh

(15) Which of following is an error detection and correction


mechanism
a) Bit stuffing
(b) Check sum
(c) even parity check
(d) Hamming codes

(16) Which is not a valid source IP address to send a packet


over the internet
(a) 5.5.5.5
(b) 10.10.10.10.
(с) 100.100.100.100
(d) 200.200 200.200

Q(17) The well known parts for SMTP and Telnet


(a) 53 and 25
(B) 25 and 21
(c) 25 and 23
(d) 23 and 20

(18) Subnetting is a technique used to


(a) Break a large network into smaller subnetworks
(B) Combine multiple small networks into one large network
(c) Assign IP addresses to network devices
(d) Determine the physical topology of a network

Q(19) Which protocol is primanly used for transferning web


pages over the Internet?
(a) SMTP (Simple Mail Transfer Protocol)
(b) FTP (File Transfer Protocol)
(c) HTTP (Hypertext Transfer Protocol)
(d) DNS (Domain Name System)

(20) Traceroute is a network diagnostic tool used to:


a. Determine the physical location of a network device
b. Measure the round trip time between two network
devices
c. identity the path that packets take from the source
to the destination
d. Check the availability of a website or network
resource

Q(21) Which of the following is the correct option for the


given query?
SELECT DISTINCT name
FROM ROBMS
WHERE ID IS NOT NULL;
(a) The query gives all the possible RDBMS names where a
finite value exists for ID
(b) The query gives the RDBMS names where a finite value
exists for ID and it excludes identical names
(c) The query gives the names of the RDBMS that have a
null ID and it also excludes identical names
(d) The query is syntactically wrong
(22) Which of the following is the correct output for the given
query?
(SELECT databaseid FROM RDBMS
WHERE SECTION = c)
EXCEPT
(SELECT databaseid FROM RDBMS WHERE id
(a) All the values of the databaseid for which section is c and
id > 10
(b) All the values of the databaseid for which section not c
and id > 10
(c) All the values of the databaseid for which section is c
and id ≤ 10
(d) All the values of the databaseid for which section not c
and id ≤ 10

(23) _____deletes a data item from a database.


a. Insert(RDBMS)
b. Drop(RDBMS).
c. Delete(RDBMS)
d. None of the mentioned.

Q(24) What is the result of the following query?


SELECT studentdatabasename
FROM RDBMS
WHERE marks > SOME (SELECT marks
FROM student
WHERE SECTION = c),
(a) The query gives all the studentdatabasename for which
marks are greater than al the students in section c
(b) The query gives all the studentdatebasename for which
the marks are greater than at least on student in section c
(C) The query gives all the studentdatabasename for which
the marks are less than all the students in section c
(d) The query is syntactically incorrect

(25) If the database modifications occur while the transaction


is still active, the transaction is said to use the modification
technique
(b) Deferred
(a) immediate
(c) More than one of the mentioned
(d) None of the mentioned

Q(26) What does the following query do?


UPDATE student
SET marks = marks*1,10;

(a) It decreases the marks of all the students by 90%


(c) It Is syntactically wrong
(b) it increases the marks of all the students by 10%
(d) It increases the marks of all the students by 110%

Q(27) for each tuple trin r do begin


FOR each tuple ts INs do BEGIN
test pair (tr, ts) TO see IF they satisfy the JOIN condition _ IF
they do, ADD tr • ts TO the RESULT;
END END
What type of join is this?

(a) Block nested loop join


(c) Hash join
(b) Nested loop join
(d) Equi join
Q(28) Choose the correct option regarding the query
SELECT branch_name, COUNT
(DISTINCT customer_name)
FROM depositor, account
WHERE depositor.account number =
account account number
GROUP BY branch id
HAVING avg(balance) = 10000:

a. The having clause allows only those tuples that


have an average balance of 10000
b. The having clause checks whether the query result is
true of not
c. The having clause does not check for any condition
d. None of the mentioned

(29) Which one of the following given statements possibly


contains the error?
a. select * from emp where empid = 10003;
b. select empid from emp where empid = 10006;
c. select empid from emp;
d. select empid where empid = 1009 and Lastname =
'GELLER

(30) In the following Query, which of the following can be


placed in the Query's blank portion to display the salary
from highest to lowest amount, and sorting the employs
name alphabetically?
(a) Ascending, Descending
(b) Asc, Desc
(c) Desc, Asc
(d) All of the above

1. Which was the first purely object-oriented programming language developed?


A. Kotlin
B. SmallTalk
C. Java
D. C++

2. Why Java is Partially OOP language?

A. It allows code to be written outside classes


B. It supports usual declaration of primitive data types
C. It does not support pointers
D. It doesn’t support all types of inheritance

3. How many objects can be created from a single class?


A. Limited to 1
B. Fixed number depends on class
C. Unlimited
D. Depends on memory available

4. Which access specifier hides data members completely?


A. public
B. protected
C. private
D. default

5. What benefit does data abstraction provide?


A. Increased program size
B. Easier debugging
C. Simplified interface
D. Reduced performance

6. Which type of inheritance allows a class to inherit from multiple parent classes?
A. Single
B. Multi-level
C. Hierarchical
D. Multiple

7. What is the relationship between a subclass and its superclass?


A. Equal
B. Peers
C. Siblings
D. Is-a
8. Which principle allows different objects to respond to the same message differently?
A. Encapsulation
B. Abstraction
C. Inheritance
D. Polymorphism

9. What operator is commonly used to overload functions for polymorphism?


A. +
B. –
C. =
D. ?

10. What is the purpose of a constructor?


A. Destroy an object
B. Print object information
C. Initialize an object
D. Access object data

1: What is the benefit of using interfaces?


A. Code flexibility
B. Data protection
C. Reduced memory usage
D. Standardized method definitions

2: Which keyword defines a class in Java?


A. class
B. object
C. type
D. structure

3: How is a method overloaded in Java?


A. By different return types
B. By different access modifiers
C. By different parameter lists
D. y different method names

4: What is the purpose of the Singleton design pattern?


A. Create multiple instances of an object
B. Ensure only one instance of an object exists
C. Share data between objects
D. Implement observer pattern

5: What is the ability of a program to manipulate its own source code called?
A. Debugging
B. Optimization
C. Metaprogramming
D. Compilation

6: Which among the following doesn’t come under OOP concept?


A. Data hiding
B. Message passing
C. Platform independent
D. Data binding

7: Which OOP concept is used to bundle data and methods that operate on the data?
A. Inheritance
B. Encapsulation
C. Polymorphism
D. Abstraction

8: What is the process by which one class acquires the properties of another class?
A. Composition
B. Polymorphism
C. Inheritance
D. Encapsulation

9: Which of the following is not true about polymorphism?


A. Helps in redefining the same functionality
B. Increases overhead of function definition always
C. It is feature of OOP
D. Ease in readability of program

10: Inheritance allows a class to:


A. Access methods of another class
B. Hide its methods
C. Extend and override methods of another class
D. None of the above

1: In OOP, what does the term ”polymorphism” mean?


A. One name, multiple forms
B. Many names, one form
C. No names, multiple forms
D. Multiple names, multiple forms

2: Which OOP concept allows a class to have multiple methods with the same name but
different parameters?
A. Overloading
B. Overriding
C. Encapsulation
D. Polymorphism

3: What is the purpose of an abstract class in OOP?


A. To create objects
B. To provide a base class for other classes
C. To hide implementation details
D. To encapsulate data

4: Which keyword is used to implement abstraction in Java?


A. abstract
B. final
C. static
D. public

5: Which of the following is NOT a fundamental OOP concept?


A. Encapsulation
B. Abstraction
C. Modularity
D. Polymorphism

6: Which among the following can show polymorphism?


A. Overloading &&
B. Overloading «
C. Overloading ||
D. Overloading +=

7: Which OOP principle is violated if a subclass tries to override a final method of its
superclass?
A. Encapsulation
B. Polymorphism
C. Inheritance
D. Abstraction

8: What is the purpose of the ”super” keyword in Java?


A. To call the superclass constructor
B. To call the subclass constructor
C. To create an object
D. To access static members of a class

9: What is the term for the ability of a class to have multiple methods with the same name but
different implementations?
A. Overloading
B. Overriding
C. Polymorphism
D. Encapsulation

10: Which of the following is a correct syntax for implementing an interface in Java?
A. class MyClass implements MyInterface { }
B. class MyClass extends MyInterface { }
C. interface MyInterface implements MyClass { }
D. interface MyInterface extends MyClass { }

1: The copy constructors can be used to .......


A. Copy an object so that it can be passed to another primitive type variable
B. Copy an object for type casting
C. Copy an object so that it can be passed to a function
D. Copy an object so that it can be passed to a class

2: What is the purpose of the ”this” keyword in Java?


A. To create an object
B. To refer to the current object
C. To call the superclass constructor
D. To access static members of a class

3: Which among the following represents correct constructor?


A. –classname()
B. classname()
C. ()classname
D. ~classname()

4: What is the purpose of the ”try”, ”catch”, and ”finally” blocks in exception handling?
A. To handle errors and exceptions
B. To create objects
C. To define a class
D. To implement polymorphism

5: Which of the following is NOT a valid modifier for a class in Java?


A. public
B. private
C. protected
D. static

6: What is the purpose of the ”instanceof” operator in Java?


A. To check if an object is an instance of a particular class
B. To create an instance of a class
C. To check if a class is abstract
D. To check if a class is final

7: What is the difference between method overloading and method overriding?


A. Overloading is static binding, and overriding is dynamic binding
B. Overloading is dynamic binding, and overriding is static binding
C. Overloading has the same method name with different parameters, while overriding
has the same method signature
D. Overloading has the same method signature, while overriding has a different method
signature

8: Which keyword is used to prevent a method from being overridden in Java?


A. static
B. final
C. abstract
D. private

9: What happens when an object is passed by reference?


A. Destructor is called at end of function
B. Destructor is called when called explicitly
C. Destructor is not called
D. Destructor is called when function is out of scope

10: How to overcome diamond problem?


A. Using separate derived class
B. Using virtual keyword with same name function
C. Can’t be done
D. Using alias name

1. In a time-space tradeoff, time is .............. proportional to space?


A. Directly
B. Indirectly
C. Equal
D. None of above

2. Which of the following is non-liner data structure?


A. Stacks
B. List
C. Strings
D. Trees

3. The operation of processing each element in the list is known as ............


A. sorting
B. merging
C. inserting
D. traversal

4. The elements of a linked list are stored?


A. In a structure
B. In an array
C. Anywhere the computer has space for them
D. In contiguous memory locations

5. The number K in A[k] is called ..........?


A. Integer
B. Subscript
C. Superscript
D. Array

6. Which of following data structure is more appropriate for implementing quick sort
iteratively?
A. Deque
B. Queue
C. Stack
D. Priority queue

7. Finding the location of a given item in a collection of items is called ..........


A. Discovering
B. Finding
C. Searching
D. Mining

8. The time complexity of quicksort is .........


A. O(n)
B. O(logn)
C. O(n2)
D. O(n logn)

9. .......... sorting is good to use when alphabetizing a large list of names.


A. Merge
B. Heap
C. Radix
D. Bubble

10. ......... form of access is used to add and remove nodes from a queue.
A. LIFO, Last In First Out
B. FIFO, First In First Out
C. Both a and b
D. None of these

1: The linear relationship between the elements represented by means of pointers is called
.............
A. Arrays
B. Linked list
C. Both
D. None

2: Which of the following data structure is required to convert arithmetic expression in infix
to its equivalent postfix notation?
A. Queue
B. Linked list
C. Binary search tree
D. Stack

3: The number of edges in a complete graph of n vertices is


A. n(n+1)/2
B. n(n−1)/ 2
C. n 2 2
D. n

4: If two trees have same structure and but different node content, then they are called ........
A. Synonyms trees
B. Joint trees
C. Equivalent trees
D. Similar trees

5: Quick sort is also known as ..........


A. merge sort
B. tree sort
C. shell sort
D. partition and exchange sort

6: The total number of comparisons in a bubble sort is


A. O(n log n)
B. O(2n)
C. O(n 2 )
D. O(n)

7: New nodes are added to the ........... of the queue.


A. Front
B. Back
C. Middle
D. Both A and B

8: The term push and pop is related to


A. Array
B. Lists
C. Stacks
D. Trees

9: Which of the following is an application of stack?


A. finding factorial
B. tower of Hanoi
C. infix to postfix
D. all of the above

10: The situation when in a linked list START=NULL is .........


A. Underflow
B. Overflow
C. Houseful
D. Saturated

1: Identify the data structure which allows deletions at both ends of the list but insertion
at only one end.
A. Input restricted dequeue
B. Output restricted queue
C. Priority queues
D. Stack

2: To represent hierarchical relationship between elements, which data structure is


suitable?
A. Deque
B. Priority
C. Tree
D. Graph

3: Minimum number of fields in each node of a doubly linked list is ..............?


A. 2
B. 3
C. 4
D. None of above
4: Which of the following data structure can’t store the non-homogeneous data
elements?
A. Arrays
B. Records
C. Pointers
D. Stacks

5: Which is the pointer associated with the availability list?


A. FIRST
B. AVAIL
C. TOP
D. REAR

6: Which of the following are two-way lists?


A. Grounded header list
B. Circular header list
C. Linked list with header and trailer nodes
D. List traversed in two directions

7: A parentheses checker program would be best implemented using


A. List
B. Queue
C. Stack
D. Any of the above

8: If two trees have same structure and node content, then they are called ..........
A. Synonyms trees
B. Joint trees
C. Equivalent trees
D. Similar trees

9: The worst-case time required to search a given element in a sorted linked list of
length n is
A. O(1)
B. O(log2 n)
C. O(n)
D. O(n log2 n)

10: Traversing a binary tree first root and then left and right subtrees called .........
traversal.
A. Postorder
B. Preorder
C. Inorder
D. None of these

1: A graph is a tree if and only if graph is


A. Directed graph
B. Contains no cycles
C. Planar
D. Completely connected

2: A binary tree in which all its levels except the last, have maximum numbers of nodes,
and all the nodes in the last level have only one child it will be its left child. Name the
tree.
A. Threaded tree
B. Complete binary tree
C. M-way search tree
D. Full binary tree

3: A full binary tree with n non-leaf nodes contains


A. log(n) nodes
B. n + 1 nodes
C. 2n − 1 nodes
D. 2n + 1 nodes

4: ............. deque is a deque which allows deletions at only one end of the list.
A. input-restricted
B. output-restricted
C. Queue
D. Heap

5: Which of the following statements is True?


A. Preorder- Process the root, Traverse the left subtree, traverse the right subtree.
B. Preorder- Traverse the left subtree, process the root, traverse the right subtree.
C. Preorder- Traverse the left subtree, traverse the right subtree, process the root.
D. None of above.

6: The data structure required to evaluate a postfix expression is


A. Queue
B. Stack
C. Tree
D. linked-list

7: Reverse polish notation is ..........


A. Prefix
B. Infix
C. Postfix
D. None

8: The time complexity of linear search algorithm over an array of n elements is


A. O(log2 n)
B. O(n)
C. O(n log2 n)
D. O(n 2 )
9: Which of the following sorting algorithms does not have a worst case running time of
O(n 2 )?
A. Insertion sort
B. Merge sort
C. Quick sort
D. Bubble sort

10: A search begins the search with the element that is located in the middle of the
array
A. serial
B. random
C. parallel
D. binary

1: The preorder traversal of a binary search tree is 15, 10, 12, 11, 20, 18, 16, 19. Which
one of the following is the post order traversal of the tree?
A. 10, 11, 12, 15, 16, 18, 19, 20
B. 11, 12, 10, 16, 19, 18, 20, 15
C. 20, 19, 18, 16, 15, 12, 11, 10
D. 19, 16, 18, 20, 11, 12, 10, 15

2: A queue is implemented using an array such that ENQUEUE and DEQUEUE


operations are performed eeiciently. Which one of the following statements is
CORRECT (n refers to the number of items in the queue)?
A. Both operations can be performed in O(1) time.
B. At most one operation can be performed in O(1) time, but the worst-case time for the
other operation will be Ω(n).
C. The worst-case time complexity for both operations will be Ω(n).
D. Worst-case time complexity for both operations will be Ω(log n).

3: The result of evaluating the postfix expression 10 5 + 60 6/ ∗ 8 − is


A. 284
B. 213
C. 142
D. 71

4: A program P reads in 500 integers in the range [0, 100], representing the scores of 500
students. It then prints the frequency of each score above 50. What would be the best
way for P to store the frequencies?
A. An array of 50 numbers
B. An array of 100 numbers
C. An array of 500 numbers
D. A dynamically allocated array of 550 numbers

5: Consider the following statements:


(i)First-in-first-out types of computations are eeiciently supported by STACKS.
(ii) Implementing LISTS on linked lists is more eeicient than implementing LISTS on an
array for almost all the basic LIST operations.
(iii) Implementing QUEUES on a circular array is more eeicient than implementing
QUEUES on a linear array with two indices.
(iv) Last-in-first-out type of computations are eeiciently supported by QUEUES.

Which of the following statements is/are true?

A. (ii) and (iii) are true


B. (i) and (ii) are true
C. (iii) and (iv) are true
D. (ii) and (iv) are true

6: The post order traversal of a binary tree is 8, 9, 6, 7, 4, 5, 2, 3, 1. The in order traversal


of the same tree is 8, 6, 9, 4, 7, 2, 5, 1, 3The height of a tree is the length of the longest
path from the root to any leaf. Then the height of the binary tree is _________.
A. 5
B. 4
C. 10
D. 1

7: Following are pass outputs of a program for an algorithm: 22, 14, 56, 7, 25, 8
Pass 1: 7, 14, 56, 22, 25, 8
Pass 2: 7, 8, 56, 22, 25, 14
And so on...
Final: 7, 8, 14, 22, 25, 56 Choose the name of the associated algorithm for the above
results.

A. Selection sort
B. Insertion sort
C. Bubble Sort
D. Merge Sort

8: Following are the pass outputs of a program for an algorithm: 22, 14, 56, 7, 25, 8
Pass 1: 14, 22, 56, 7, 25, 8
Pass 2: 14, 22, 56, 7, 25, 8
Pass 3: 7, 14, 22, 56, 25, 8
And so on...
Final: 7, 8, 14, 22, 25, 56 Choose the name of the associated algorithm for the above
results.

A. Selection sort
B. Insertion sort
C. Bubble Sort
D. Merge Sort

9: Following are the pass outputs of a program for an algorithm: 22, 14, 56, 7, 25, 8
Pass 1: 14, 22, 7, 25, 8, 56
Pass 2: 14, 7, 22, 8, 25, 56
And so on...
Final: 7, 8, 14, 22, 25, 56 Choose the name of the associated algorithm for the above
results.

(A) Selection sort


(B) Insertion sort
(C) Bubble Sort
(D) Merge Sort

10: Array representation of Binary tree


A. 0 1 2 3 4 5 6
7 11 2 7 1 11 9
B. 0 1 2 3 4 5 6
7 11 7 1 2 11 9
C. 0 1 2 3 4 5 6
7 1 11 11 9 2 7
D. Any of the above

1. Find the recurrence relation of the Quick Sort algorithm in the worst case.
A. T(n) = T(n/10) + T(9n/10) + O(n)
B. T(n) = T(n − 1) + T(0) + O(n)
C. T(n) = 2T(n/2) + O(n)
D. T(n) = T(n − 2) + O(n)

2. Let us have an algorithm to find the median of the unsorted array having complexity
O(n). Now we have modified the quicksort algorithm and using the median algorithm to
find the pivot element. What will be the complexity of this modified quicksort algorithm
in the worst case?
A. O(log log n)
B. O(n)
C. O(n 2 )
D. O(n log n)

3. If the array is already sorted or almost sorted then which algorithm will give the best
results?
A. Quick Sort
B. Merge Sort
C. Heap Sort
D. Insertion Sort

4. If Swap operation is very costly then which sorting technique you will choose to sort
the unsorted array?
A. Insertion Sort
B. Selection Sort
C. Merge Sort
D. Heap Sort

5. Suppose you have 2GB Data and you have to sort it, but you have only 100MB main
memory available with you, which sorting technique you are going to apply?
A. Merge Sort
B. Insertion Sort
C. Heap Sort
D. Quick Sort

6. What is the recurrence relation of Binary Search in Worst case?


A. T(n) = T(n/2) + O(1) and T(1) = T(0) = O(1)
B. T(n) = T(n − 1) + O(1) and T(1) = T(0) = O(1)
C. T(n) = 2T(n/2) + O(1) and T(1) = T(0) = O(1)
D. T(n) = T(n − 2) + O(1) and T(1) = T(0) = O(1)

7. Average number of comparisons in linear search when the element is present in the
list is:
A. n
B. n/2
C. (n + 1)/2
D. (n − 1)/2

8. Average number of comparisons in linear search when the element is present in the
list is:
A. n
B. n/2
C. (n + 1)/2
D. (n − 1)/2

9. If we have 11 sorted elements in an array and we apply Binary search to find the
element and each time it is a successful search. What will be the average number of
comparisons we need to do?
A. 3.46
B. 3.0
C. 3.33
D. 2.81

10. Average case complexity of Linear Search occurs when:


A. Item is available exactly in the mid of the list.
B. Item is available somewhere in between the list.
C. Item is at the end of the list.
D. Item is not available in the list.

1: Which of the Hash Function will create a cluster in the hash table?
A. h(k) = k
B. h(k) = k%m
C. h(k) = ( k m + k · m ) + k%m
D. h(k) = (k + 1) %m + k m

2: Hash Table T has 25 slots which are going to store 2000 elements. What will be the
load factor?
A. 0.0125
B. 50000
C. 1.25
D. 80

3: Let a Hash Function distributes keys uniformly in the hash table. The hash table has
size 50. After how many keys are added will the probability of collision become 0.5?
A. 20
B. 25
C. 10
D. 30

4: Benefit of chaining over open addressing is:


A. Deletion is easier
B. Space used is less
C. Complexity of the search operation is less
D. None of these

5: Insert the characters of the string KRP Y SNJM into a hash table of size 10. Use the
hash function h(x) = (ord(x) − ord(”A”) + 1) mod 10. If linear probing is used to resolve
collisions, then the following insertion causes a collision. ord(x) is a function that
returns the alphabetical order of the letter.
A. P
B. M
C. C
D. K

6: Which is the most eeicient algorithm to find a cycle in a graph?


A. BFS
B. DFS
C. Prim’s Algorithm
D. Kruskal Algorithm

7: How is traversal of a graph dieerent from a tree?


A. BFS of a graph uses a queue, but a time-eeicient BFS of a tree is recursive.
B. DFS of a graph uses a stack, but inorder traversal of a tree is recursive.
C. There can be a loop in a graph so we must maintain a visited flag for every vertex.
D. All of the above.

8: To implement Dijkstra’s shortest path algorithm on unweighted graphs so that it runs


in linear time, the data structure to be used is:
A. Queue
B. Stack
C. Heap
D. Binary Tree

9: Which of the following algorithms can be used to eeiciently calculate single source
shortest paths in a Directed Acyclic Graph?
A. Topological Sort
B. Bellman-Ford
C. Dijkstra
D. Prim’s

10: Given a directed graph where the weight of every edge is the same, we can eeiciently
find the shortest path from a given source to destination using:
A. DFS
B. BFS
C. Dijkstra
D. Kruskal

1: Which of the following problems can be eeiciently solved using Greedy


Programming?
A. Traveling Salesman Problem
B. Knapsack Problem
C. Shortest Path Problem
D. Fractional Knapsack Problem

2: Which of the following statements is true regarding Greedy Algorithms?


A. They always guarantee optimal solutions for any problem.
B. They are not suitable for problems where a globally optimal solution is required.
C. They are primarily based on backtracking.
D. They are applicable only to problems with small input sizes.

3: What is the time complexity of the Greedy Algorithm for Hueman coding?
A. O(n log n)
B. O(n 2 )
C. O(n)
D. O(log n)

4: Which of the following problems is NOT solved using a Greedy Algorithm?


A. Prim’s Algorithm for Minimum Spanning Tree
B. Dijkstra’s Algorithm for Shortest Path
C. Traveling Salesman Problem
D. Knapsack Problem

5: In the context of the Fractional Knapsack Problem, if the available capacity is 10 and
there are items with weights {5, 3, 8} and values {10, 6, 12}, what is the maximum value
that can be obtained using a greedy approach?
A. 15
B. 18
C. 22
D. 28

6: In the context of Hueman coding, if the frequencies of characters are {2, 3, 7, 10} and
a greedy algorithm is used to build the Hueman tree, what is the total number of bits
needed to represent the entire message?
a. 18
b. 20
c. 24
d. 28

7: For a given graph, if Prim’s algorithm is used to find the minimum spanning tree, and
the graph is represented using an adjacency matrix, what is the time complexity in
terms of the number of vertices (V)?
A. O(V )
B. O(V 2 )
C. O(V log V )
D. O(V 3 )

8: In the Fractional Knapsack Problem, if the available capacity is 15 and there are items
with weights {8, 4, 6} and values {16, 10, 12}, what is the optimal solution obtained using
a greedy approach?
A. 30
B. 28
C. 26
D. 24

9: What is the time complexity of the greedy algorithm for job scheduling with
deadlines?
A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)

10: For a given graph with weighted edges, if Kruskal’s algorithm is applied to find the
minimum spanning tree, what is the time complexity for a graph with V vertices and E
edges?
A. O(V )
B. O(E)
C. O(V log V )
D. O(E log E)

1: In the Merge Sort algorithm, what is the time complexity for sorting an array of n
elements?
A. O(n)
B. O(log n)
C. O(n log n)
D. O(n 2 )

2: What is the base case in most Divide and Conquer algorithms?


A. When the input size becomes zero
B. When the input size becomes one
C. When the input size becomes two
D. When the input size becomes a prime number

3: In the Quicksort algorithm, what is the role of the ”pivot” element?


A. It is the smallest element in the array
B. It is the largest element in the array
C. It is used to partition the array into smaller and greater elements
D. It is the middle element of the array

4: Which of the following is a disadvantage of the Divide and Conquer approach?


A. It is dieicult to implement
B. It often requires extra space
C. It is not suitable for parallel processing
D. It may have a high constant factor in the time complexity

5: What is the time complexity of the Merge Sort algorithm for sorting an array of size n?
A. O(n)
B. O(log n)
C. O(n log n)
D. O(n 2 )

6: If an algorithm divides the problem into five subproblems and each subproblem is
solved independently, what would be its recurrence relation for time complexity?
A. T(n) = 5 · T(n/5)
B. T(n) = T(n/5) + T(4n/5)
C. T(n) = T(n/2) + 5
D. T(n) = 5 · T(n)

7: If a Divide and Conquer algorithm has a recurrence relation T(n) = T(n/2)+O(n), what is
its time complexity?
A. O(n)
B. O(log n)
C. O(n log n)
D. O(n 2 )

8: If the size of the input is halved in each recursive call and an additional linear amount
of work is done, what is the overall time complexity of the algorithm?
A. O(log n)
B. O(n)
C. O(n log n)
D. O(n 2 )
9: Consider a recursive algorithm with a time complexity given by the recurrence
relation T(n) = 3T(n/4) + n 2 . What is the time complexity of this algorithm using the
Master Theorem?
A. O(n)
B. O(n log n)
C. O(n 2 log n)
D. O(n 2 )

10: The time complexity of an algorithm is given by T(n) = T(n/2) + T(n/4) + n. What is the
time complexity of the algorithm?
A. O(n log n)
B. O(n 2 )
C. O(n 2 log n)
D. O(n 3 )

1: Which of the following is a key feature of problems suitable for dynamic


programming?
A. They can be solved using a brute-force approach
B. They exhibit optimal substructure and overlapping subproblems
C. They are always easy to solve
D. They involve recursion

2: In dynamic programming, what is meant by ”optimal substructure”?


A. The smallest subproblem is always the optimal solution
B. The optimal solution of a problem can be constructed from optimal solutions of
its subproblems
C. The subproblems are always solved in an optimal way
D. The optimal solution is always achieved using a brute-force approach

3: What is memorization in the context of dynamic programming?


A. A technique for storing and reusing previously computed results to avoid
redundant computations
B. A method for writing code using memo pads
C. A way of measuring the time complexity of a dynamic programming algorithm
D. A type of optimization that prioritizes memory over speed

4: If a dynamic programming algorithm uses the tabulation approach to solve a problem


of size n, and the table has dimensions n × n, what is the space complexity of the
algorithm?
A. O(n)
B. O(n 2 )
C. O(log n)
D. O(1)

5: Which of the following is an example of a problem that can be eeiciently solved using
dynamic programming?
A. Sorting an array
B. Finding the maximum element in an array
C. Longest Common Subsequence
D. Binary search

6: In the Fibonacci sequence, if F(0) = 0 and F(1) = 1, what is the value of F(5) using
dynamic programming?
A. 3
B. 5
C. 8
D. 13

7: For the Longest Common Subsequence (LCS) problem, if the input sequences are
”ABCD” and ”ACDF,” what is the length of the LCS using dynamic programming?
A. 2
B. 3
C. 4
D. 5

8: If a dynamic programming algorithm uses memorization and the result of F(3) is


already computed, how many times will F(3) be recalculated in the process of solving
F(5)?
A. 0
B. 1
C. 2
D. 3

9: If a dynamic programming algorithm has a recurrence relation T(n) = T(n − 1) + T(n − 2)


and base cases T(0) = 1, T(1) = 1, what is the time complexity of the algorithm in terms of
n?
A. O(n)
B. O(2n )
C. O(n 2 )
D. O(log n)

10: For the Knapsack problem, if the maximum capacity is 10 and there are items with
weights [2, 4, 5] and values [6, 8, 7], what is the maximum value that can be achieved
using dynamic programming?
A. 13
B. 14
C. 15
D. 16

You might also like