20 Sample GATE CSE Questions with Answers for Practice and Preparation (Set 2)

Web Online Works

 


Question 1: Which data structure is typically used to implement a queue?

A) Stack

B) Linked List

C) Array

D) Binary Tree

Answer: The correct answer is: B) Linked List

A linked list is typically used to implement a queue, as it provides efficient insertion and deletion operations at both ends.

Question 2: What is the time complexity of the best-case scenario for quicksort?

Answer 2: The best-case time complexity for quicksort is O(n log n), where n is the number of elements to be sorted. This occurs when the pivot element chosen is the median of the array, resulting in a balanced partition at each step.

Question 3: What is the purpose of the OSI (Open Systems Interconnection) model?

Answer 3: The purpose of the OSI model is to provide a conceptual framework for understanding and designing computer network protocols. It defines seven layers (Physical, Data Link, Network, Transport, Session, Presentation, and Application) that describe the different aspects of network communication.

Question 4: Which of the following is not a valid type of SQL join?

A) INNER JOIN

B) LEFT JOIN

C) OUTER JOIN

D) CROSS JOIN

Answer 4: The correct answer is: C) OUTER JOIN

OUTER JOIN is not a specific type of join in SQL. However, INNER JOIN, LEFT JOIN, and CROSS JOIN are valid types of SQL joins.

Question 5: Which sorting algorithm has a time complexity of O(n^2) in the worst case?

A) Merge sort

B) Quick sort

C) Heap sort

D) Bubble sort

Answer 5: The correct answer is: D) Bubble sort

Bubble sort has a worst-case time complexity of O(n^2), making it inefficient for large input sizes.

Question 6: Consider the following code snippet:

def fibonacci(n):

    if n <= 1:

        return n

    else:

        return fibonacci(n-1) + fibonacci(n-2)

 result = fibonacci(6)

print(result)

What is the output of the above code?

Answer 6: The output of the above code is: 8

The fibonacci() function calculates the nth Fibonacci number recursively. In this case, the 6th Fibonacci number is 8.

Question 7: Which of the following sorting algorithms is based on the divide-and-conquer strategy?

A) Insertion sort

B) Selection sort

C) Merge sort

D) Bubble sort

Answer 7: The correct answer is: C) Merge sort

Merge sort is a sorting algorithm that uses the divide-and-conquer strategy by recursively dividing the input into smaller subproblems, solving them, and merging the sorted subarrays to obtain the final sorted result.

Question 8: What is the purpose of a cache memory in a computer system?

Answer 8: The purpose of a cache memory is to store frequently accessed data or instructions in a faster memory close to the CPU. It acts as a buffer between the CPU and main memory, reducing the average access time and improving system performance.

Question 9: Which of the following is a dynamic programming algorithm used to solve the shortest path problem?

A) Dijkstra's algorithm

B) Kruskal's algorithm

C) Prim's algorithm

D) Bellman-Ford algorithm

Answer 9:The correct answer is: D) Bellman-Ford algorithm

The Bellman-Ford algorithm is a dynamic programming algorithm used to find the shortest path in a weighted graph, even in the presence of negative edge weights.

Question 10: What is the purpose of a firewall in computer networks?

Answer 10: A firewall is a network security device that monitors and filters incoming and outgoing network traffic based on predetermined security rules. It acts as a barrier between internal and external networks, protecting against unauthorized access and threats.

Question 11: Which of the following is an example of a hashing algorithm?

A) Quick sort

B) Breadth-first search (BFS)

C) MD5

D) Dijkstra's algorithm

Answer 11: The correct answer is: C) MD5

MD5 (Message Digest Algorithm 5) is an example of a hashing algorithm. It is commonly used to generate a unique hash value or fingerprint for a given input data, typically used for data integrity and password storage.

Question 12: What is the purpose of an operating system's scheduler?

Answer 12: The scheduler in an operating system is responsible for determining which processes or threads should be allocated CPU time and in what order. It manages the execution of processes, ensures fairness, and optimizes resource utilization.

Question 13: Which of the following is an example of a greedy algorithm?

A) Binary search

B) Depth-first search (DFS)

C) Kruskal's algorithm

D) Radix sort

Answer 13: The correct answer is: C) Kruskal's algorithm

Kruskal's algorithm is an example of a greedy algorithm used to find a minimum spanning tree in a graph. Greedy algorithms make locally optimal choices at each step to reach a global optimum.

Question 14: What is the purpose of the HTTP HEAD request method?

Answer 14: The HTTP HEAD request method is used to retrieve only the headers of a resource from a web server, without retrieving the actual content.

Question 15: Consider the following code snippet:

def func(n):

    if n <= 1:

        return 1

    else:

        return n * func(n-1)

result = func(5)

print(result)

What is the output of the above code?

Answer 15: The output of the above code is: 120

The func() function calculates the factorial of a number n recursively. In this case, the factorial of 5 is 120.

Question 16: Which of the following data structures is typically used to implement a symbol table in a compiler?

A) Stack

B) Queue

C) Hash table

D) Tree

Answer 16: The correct answer is: C) Hash table

A hash table is typically used to implement a symbol table in a compiler. It allows efficient storage and retrieval of key-value pairs using a hashing function.

Question 17: What is the purpose of the SQL GROUP BY clause?

Answer 17: The GROUP BY clause in SQL is used to group rows based on one or more columns. It is typically used in conjunction with aggregate functions like SUM, COUNT, AVG, etc., to perform calculations on grouped data.

Question 18: Which of the following is an example of a scheduling algorithm used in operating systems?

A) A* algorithm

B) Depth-first search (DFS)

C) Round Robin (RR)

D) Floyd-Warshall algorithm

Answer 18: The correct answer is: C) Round Robin (RR)

Round Robin is a scheduling algorithm used in operating systems to allocate CPU time to processes in a cyclic manner, giving each process a fixed time slice.

Question 19: In computer networks, what is the purpose of the subnet mask?

Answer 19: The subnet mask is used in computer networks to determine the network and host portions of an IP address. It is used in conjunction with the IP address to perform network addressing and routing.

Question 20: Which of the following is an example of a graph traversal algorithm?

A) Quick sort

B) Breadth-first search (BFS)

C) Binary search

D) Dijkstra's algorithm

Answer 20: The correct answer is: B) Breadth-first search (BFS)

Post a Comment

0Comments
Post a Comment (0)