CSE357 MCQs – Combinatorial Studies for Placement

0

This comprehensive MCQ guide for CSE357 - Combinatorial Studies is designed to help LPU students prepare for exams and placements. Covering essential topics with well-structured multiple-choice questions, this resource enhances understanding and problem-solving skills. Ideal for students aiming to strengthen their grasp of combinatorial concepts, algorithms, and problem-solving techniques. Download now from GeeksforCampus.in and boost your preparation! 🚀


Unit 1

  1. Which of the following is NOT a mechanism for inter-process communication?
    a) Shared Memory
    b) Message Passing
    c) Thread Scheduling
    d) Signals
    Answer: c) Thread Scheduling

  2. What is the key advantage of using message passing for inter-process communication?
    a) Processes remain loosely coupled
    b) Higher memory efficiency
    c) Less CPU overhead
    d) Faster than shared memory
    Answer: a) Processes remain loosely coupled

  3. What system call is used in UNIX for sending a signal to a process?
    a) send()
    b) kill()
    c) recv()
    d) notify()
    Answer: b) kill()

  4. In inter-process communication, what does a semaphore do?
    a) Prevents deadlocks
    b) Enables process synchronization
    c) Allocates memory dynamically
    d) Controls CPU scheduling
    Answer: b) Enables process synchronization

  5. Which of the following is an example of indirect inter-process communication?
    a) Using pipes
    b) Using message queues
    c) Using shared memory
    d) Using mutex locks
    Answer: b) Using message queues

  6. Which disk scheduling algorithm is considered the fairest in serving all requests?
    a) FCFS
    b) SSTF
    c) SCAN
    d) C-SCAN
    Answer: a) FCFS

  7. Which scheduling algorithm minimizes the seek time?
    a) FCFS
    b) SSTF
    c) LOOK
    d) C-SCAN
    Answer: b) SSTF

  8. In the SCAN disk scheduling algorithm, what is the main advantage?
    a) Serves all requests in the order they arrive
    b) Prevents starvation of requests
    c) Works faster than C-SCAN
    d) Always picks the shortest job
    Answer: b) Prevents starvation of requests

  9. What does the term "seek time" refer to in disk scheduling?
    a) Time taken to move the disk arm to the requested track
    b) Time taken to read data
    c) Time taken to write data
    d) Time taken to rotate the disk
    Answer: a) Time taken to move the disk arm to the requested track

  10. Which disk scheduling algorithm is best suited for a system with a high number of requests?
    a) SSTF
    b) FCFS
    c) C-SCAN
    d) LOOK
    Answer: c) C-SCAN

  11. Which of the following is NOT a function of an operating system?
    a) Memory management
    b) Process scheduling
    c) Data compression
    d) File management
    Answer: c) Data compression

  12. What is the main goal of an operating system?
    a) Provide an interface between user and hardware
    b) Execute user applications
    c) Manage system resources efficiently
    d) All of the above
    Answer: d) All of the above

  13. What is an essential feature of a multi-user operating system?
    a) Single-tasking
    b) Multi-tasking
    c) File locking
    d) Manual memory allocation
    Answer: b) Multi-tasking

  14. What type of operating system is used in real-time applications?
    a) Batch
    b) Multiprocessing
    c) Real-time
    d) Distributed
    Answer: c) Real-time

  15. What is the purpose of the kernel in an operating system?
    a) Manage hardware and system resources
    b) Provide a user interface
    c) Manage database transactions
    d) Encrypt system files
    Answer: a) Manage hardware and system resources

  16. Which type of operating system is used for supercomputers?
    a) Embedded OS
    b) Batch OS
    c) Distributed OS
    d) Network OS
    Answer: c) Distributed OS

  17. Which of the following is an example of a mobile operating system?
    a) Windows 10
    b) Android
    c) Ubuntu
    d) macOS
    Answer: b) Android

  18. What is the key feature of a time-sharing operating system?
    a) Processes are executed in real-time
    b) Multiple users can use the system simultaneously
    c) All processes run with equal priority
    d) Uses batch processing techniques
    Answer: b) Multiple users can use the system simultaneously

  19. What kind of OS is designed for microcontrollers?
    a) Real-time OS
    b) Multi-user OS
    c) Network OS
    d) Distributed OS
    Answer: a) Real-time OS

  20. What type of operating system is designed to support multiple users over a network?
    a) Real-time OS
    b) Network OS
    c) Embedded OS
    d) Mobile OS
    Answer: b) Network OS

  21. What is a page fault in an operating system?
    a) An error in the paging system
    b) When a process accesses a page that is not in memory
    c) A failure in the virtual memory system
    d) When memory runs out
    Answer: b) When a process accesses a page that is not in memory

  22. Which memory management technique allows the execution of a program larger than the physical memory?
    a) Paging
    b) Segmentation
    c) Virtual Memory
    d) Partitioning
    Answer: c) Virtual Memory

  23. What is the main disadvantage of using paging?
    a) Increases memory fragmentation
    b) Increases execution speed
    c) Reduces I/O operations
    d) Increases memory access time
    Answer: d) Increases memory access time

  24. Which scheduling algorithm assigns the CPU to the process with the shortest execution time?
    a) FCFS
    b) SJF
    c) Round Robin
    d) Priority Scheduling
    Answer: b) SJF

  25. In Round Robin scheduling, what happens when a process's time quantum expires?
    a) It is terminated
    b) It moves to the end of the queue
    c) It is given more time
    d) It remains at the front of the queue
    Answer: b) It moves to the end of the queue

  26. What problem can occur if multiple processes access shared resources simultaneously?
    a) Starvation
    b) Deadlock
    c) Aging
    d) Fragmentation
    Answer: b) Deadlock

  27. What is a solution to prevent race conditions?
    a) Mutex locks
    b) Virtual memory
    c) Paging
    d) Deadlock detection
    Answer: a) Mutex locks

  28. What is the role of a monitor in process synchronization?
    a) Prevents race conditions
    b) Increases CPU usage
    c) Avoids page faults
    d) Improves scheduling
    Answer: a) Prevents race conditions

  29. What is the purpose of a semaphore in process synchronization?
    a) Prevents deadlocks
    b) Manages access to shared resources
    c) Schedules processes
    d) Increases CPU speed
    Answer: b) Manages access to shared resources

  30. Which of the following synchronization mechanisms works on busy waiting?
    a) Mutex
    b) Spinlock
    c) Semaphore
    d) Deadlock
    Answer: b) Spinlock

Unit - 2

Q1. What is the primary purpose of a Database Management System (DBMS)?
A) Store data permanently
B) Retrieve and manipulate data efficiently
C) Ensure hardware compatibility
D) Provide a user-friendly interface only
Answer: B) Retrieve and manipulate data efficiently

Q2. Which of the following is a characteristic of an RDBMS?
A) Uses hierarchical data storage
B) Stores data in a flat-file format
C) Uses tables with rows and columns
D) Does not support ACID properties
Answer: C) Uses tables with rows and columns

Q3. In a relational database, what does each row in a table represent?
A) An attribute
B) A record
C) A field
D) A schema
Answer: B) A record

Q4. Which of the following is NOT a type of DBMS?
A) Hierarchical
B) Network
C) Flat-file
D) Vector-based
Answer: D) Vector-based

Q5. What is the role of a DBMS in ensuring data security?
A) Controlling access rights
B) Deleting unnecessary data
C) Encrypting all stored data
D) Providing external backups
Answer: A) Controlling access rights

Q6. What does SQL stand for?
A) Structured Query Language
B) Sequential Query Language
C) Systematic Query Language
D) Standardized Query Language
Answer: A) Structured Query Language

Q7. In a database table, which component represents a single piece of data?
A) Table
B) Field
C) Record
D) Schema
Answer: B) Field

Q8. Which SQL statement is used to remove all rows from a table without deleting the table itself?
A) DELETE
B) DROP
C) TRUNCATE
D) ALTER
Answer: C) TRUNCATE

Q9. What is the correct SQL command to change a value in an existing record?
A) MODIFY
B) CHANGE
C) UPDATE
D) ALTER
Answer: C) UPDATE

Q10. Which SQL clause is used to filter query results?
A) WHERE
B) HAVING
C) ORDER BY
D) SELECT
Answer: A) WHERE

Q11. Which key uniquely identifies a record in a table?
A) Foreign key
B) Primary key
C) Composite key
D) Candidate key
Answer: B) Primary key

Q12. Which key is used to link two tables in a relational database?
A) Candidate key
B) Foreign key
C) Super key
D) Primary key
Answer: B) Foreign key

Q13. What type of key is a combination of two or more attributes to uniquely identify a record?
A) Super key
B) Composite key
C) Candidate key
D) Foreign key
Answer: B) Composite key

Q14. What ensures that a foreign key value must match a primary key value in another table?
A) Entity integrity
B) Referential integrity
C) Domain integrity
D) Functional dependency
Answer: B) Referential integrity

Q15. Which integrity constraint ensures that no primary key column can have a NULL value?
A) Referential integrity
B) Entity integrity
C) Domain integrity
D) Functional integrity
Answer: B) Entity integrity

Q16. What is the main purpose of normalization in a database?
A) To minimize redundancy
B) To improve query speed
C) To increase storage
D) To create more tables
Answer: A) To minimize redundancy

Q17. Which normal form eliminates repeating groups in a table?
A) 1NF
B) 2NF
C) 3NF
D) BCNF
Answer: A) 1NF

Q18. A table is in 2NF if it is in 1NF and:
A) Contains no transitive dependencies
B) Has a single-column primary key
C) Has no partial dependencies
D) Has at least three columns
Answer: C) Has no partial dependencies

Q19. Which of the following must be removed to achieve Boyce-Codd Normal Form (BCNF)?
A) Redundant data
B) Partial dependencies
C) Transitive dependencies
D) Functional dependencies where non-key attributes determine part of the primary key
Answer: D) Functional dependencies where non-key attributes determine part of the primary key

Q20. Which normal form is considered the strictest in terms of dependency constraints?
A) 1NF
B) 2NF
C) 3NF
D) 5NF
Answer: D) 5NF

Q21. What is a database transaction?
A) A set of database operations that must be executed sequentially
B) A single SQL query
C) A program compiled in SQL
D) A process that permanently deletes data
Answer: A) A set of database operations that must be executed sequentially

Q22. Which of the following is NOT a property of a transaction?
A) Atomicity
B) Consistency
C) Redundancy
D) Durability
Answer: C) Redundancy

Q23. What does the ACID property "Atomicity" ensure?
A) A transaction must complete within a fixed time
B) A transaction is executed only if memory is available
C) A transaction is either fully completed or not executed at all
D) A transaction always increases database efficiency
Answer: C) A transaction is either fully completed or not executed at all

Q24. What is the purpose of a database lock in transaction management?
A) To delete conflicting records
B) To prevent concurrent access issues
C) To improve query speed
D) To ensure only SELECT queries are executed
Answer: B) To prevent concurrent access issues

Q25. Which of the following SQL commands is used to start a transaction?
A) BEGIN TRANSACTION
B) START TRANSACTION
C) COMMIT
D) ROLLBACK
Answer: B) START TRANSACTION

Q26. What happens when a transaction is rolled back?
A) All its changes are permanently saved
B) The transaction restarts automatically
C) The database returns to its previous state before the transaction
D) The system shuts down
Answer: C) The database returns to its previous state before the transaction

Q27. What is deadlock in transaction management?
A) A state where two transactions wait indefinitely for resources locked by each other
B) A process where all transactions execute successfully
C) A backup mechanism for the database
D) A security feature
Answer: A) A state where two transactions wait indefinitely for resources locked by each other

Q28. Which schedule is always conflict-serializable?
A) Preemptive scheduling
B) Strict 2PL
C) Non-deterministic scheduling
D) Read-Write scheduling
Answer: B) Strict 2PL

Q29. What does "Durability" in ACID properties ensure?
A) The transaction's effects are permanent
B) The transaction can be reversed anytime
C) The database refreshes after every transaction
D) The transaction logs are deleted
Answer: A) The transaction's effects are permanent

Q30. Which of the following is a concurrency control technique?
A) Hashing
B) Indexing
C) Timestamp ordering
D) Sorting
Answer: C) Timestamp ordering

Unit 3

  1. What is the primary purpose of a computer network?
    a) To play games
    b) To connect multiple computers for resource sharing
    c) To create backups
    d) To store personal files
    Answer: b) To connect multiple computers for resource sharing

  2. What is the key advantage of packet-switched networks over circuit-switched networks?
    a) Dedicated path for communication
    b) More efficient use of bandwidth
    c) Reduced transmission delay
    d) Fixed resource allocation
    Answer: b) More efficient use of bandwidth

  3. What does bandwidth refer to in networking?
    a) The time it takes for a packet to travel
    b) The amount of data that can be transmitted in a given time
    c) The number of devices on a network
    d) The physical length of the cables used
    Answer: b) The amount of data that can be transmitted in a given time

  4. What is latency in a network?
    a) The delay before data transfer begins
    b) The speed at which data is transmitted
    c) The amount of data that can be sent
    d) The number of errors in a transmission
    Answer: a) The delay before data transfer begins

  5. Which of the following network devices works at the physical layer of the OSI model?
    a) Router
    b) Hub
    c) Switch
    d) Firewall
    Answer: b) Hub

  6. What type of network covers a large geographical area?
    a) LAN
    b) PAN
    c) WAN
    d) MAN
    Answer: c) WAN

  7. Which of the following is an example of a personal area network (PAN)?
    a) Bluetooth connection between a phone and a laptop
    b) A Wi-Fi network in a college
    c) A fiber-optic connection between two cities
    d) A satellite communication system
    Answer: a) Bluetooth connection between a phone and a laptop

  8. In a client-server network, which device provides services?
    a) Client
    b) Router
    c) Server
    d) Hub
    Answer: c) Server

  9. A peer-to-peer (P2P) network is best suited for:
    a) Large corporate environments
    b) Home or small office networks
    c) Data centers
    d) Large-scale cloud computing
    Answer: b) Home or small office networks

  10. The main advantage of a WAN over a LAN is:
    a) Faster speed
    b) Larger coverage area
    c) Simpler setup
    d) Better security
    Answer: b) Larger coverage area

  11. Which network topology has a central hub that connects all devices?
    a) Bus
    b) Ring
    c) Star
    d) Mesh
    Answer: c) Star

  12. In a mesh topology, how many links are needed for 5 devices in a full mesh network?
    a) 10
    b) 15
    c) 20
    d) 5
    Answer: b) 15

  13. Which cabling is commonly used in Ethernet networks?
    a) Coaxial cable
    b) Twisted pair cable
    c) Fiber optic cable
    d) HDMI cable
    Answer: b) Twisted pair cable

  14. Which transmission medium provides the highest data transmission speed?
    a) Copper wire
    b) Optical fiber
    c) Coaxial cable
    d) Radio waves
    Answer: b) Optical fiber

  15. What is a disadvantage of wireless networks compared to wired networks?
    a) Slower speeds
    b) Higher cost
    c) Less security
    d) Both a & c
    Answer: d) Both a & c

  16. How many layers are in the OSI model?
    a) 5
    b) 6
    c) 7
    d) 8
    Answer: c) 7

  17. What layer of the OSI model is responsible for routing?
    a) Transport
    b) Network
    c) Data Link
    d) Physical
    Answer: b) Network

  18. Which protocol is used at the transport layer of the TCP/IP model?
    a) IP
    b) UDP
    c) HTTP
    d) ARP
    Answer: b) UDP

  19. What is the purpose of the transport layer in the OSI model?
    a) Addressing
    b) Routing
    c) Error detection and reliable communication
    d) Frame synchronization
    Answer: c) Error detection and reliable communication

  20. Which protocol is used for domain name resolution?
    a) DHCP
    b) DNS
    c) FTP
    d) SMTP
    Answer: b) DNS

  21. How many bits are in an IPv4 address?
    a) 16
    b) 32
    c) 64
    d) 128
    Answer: b) 32

  22. What is the default subnet mask for a Class C network?
    a) 255.0.0.0
    b) 255.255.0.0
    c) 255.255.255.0
    d) 255.255.255.255
    Answer: c) 255.255.255.0

  23. What is the primary function of a router?
    a) Filter network traffic
    b) Forward data packets between networks
    c) Connect multiple devices in a LAN
    d) Manage IP addressing
    Answer: b) Forward data packets between networks

  24. What type of routing is used when a network administrator manually sets up routes?
    a) Static routing
    b) Dynamic routing
    c) Hybrid routing
    d) Packet switching
    Answer: a) Static routing

  25. Which protocol assigns IP addresses dynamically?
    a) DNS
    b) ARP
    c) DHCP
    d) SMTP
    Answer: c) DHCP

  26. Which protocol is used for email retrieval?
    a) HTTP
    b) SMTP
    c) POP3
    d) FTP
    Answer: c) POP3

  27. Which protocol is responsible for transferring web pages?
    a) FTP
    b) HTTP
    c) DHCP
    d) SMTP
    Answer: b) HTTP

  28. What does ARP (Address Resolution Protocol) do?
    a) Maps IP addresses to MAC addresses
    b) Assigns IP addresses dynamically
    c) Manages email communication
    d) Encrypts data packets
    Answer: a) Maps IP addresses to MAC addresses

  29. What is the function of RARP?
    a) Resolves IP to MAC
    b) Resolves MAC to IP
    c) Encrypts data packets
    d) Manages routing tables
    Answer: b) Resolves MAC to IP

  30. Which protocol is used for secure file transfer?
    a) FTP
    b) SFTP
    c) SMTP
    d) POP3
    Answer: b) SFTP

Unit - 4

Q1. Which of the following is NOT a pillar of Object-Oriented Programming?
A) Encapsulation
B) Inheritance
C) Polymorphism
D) Compilation
Answer: D) Compilation

Q2. What does encapsulation in OOP refer to?
A) The ability to define multiple methods with the same name
B) Restricting access to certain details of an object
C) The process of reusing code from another class
D) The ability to create new classes from existing classes
Answer: B) Restricting access to certain details of an object

Q3. Which OOP principle allows a subclass to acquire properties and behavior from a superclass?
A) Encapsulation
B) Polymorphism
C) Inheritance
D) Abstraction
Answer: C) Inheritance

Q4. Which OOP concept allows multiple methods to have the same name but different implementations?
A) Abstraction
B) Polymorphism
C) Encapsulation
D) Association
Answer: B) Polymorphism

Q5. Which of the following best defines abstraction in OOP?
A) Hiding unnecessary details while showing essential features
B) Storing data and methods together
C) Modifying methods in subclasses
D) Copying attributes from one object to another
Answer: A) Hiding unnecessary details while showing essential features

Q6. What is the main function of a compiler?
A) To translate code line by line into machine code
B) To execute code directly
C) To convert high-level code into machine code at once
D) To store data in a database
Answer: C) To convert high-level code into machine code at once

Q7. Which programming languages typically use an interpreter instead of a compiler?
A) C, C++
B) Java, C#
C) Python, JavaScript
D) Assembly, Fortran
Answer: C) Python, JavaScript

Q8. What is the major difference between a compiler and an interpreter?
A) A compiler executes code faster than an interpreter
B) An interpreter translates the entire code at once
C) A compiler does not generate executable files
D) An interpreter runs the code first, then translates it
Answer: A) A compiler executes code faster than an interpreter

Q9. Which of the following is an example of an interpreted language?
A) C++
B) Java
C) Python
D) Assembly
Answer: C) Python

Q10. What is Just-In-Time (JIT) compilation?
A) A technique to convert high-level language to machine code before execution
B) A method of running code without translating it
C) A feature that allows direct execution of source code
D) A way to interpret the code dynamically during runtime
Answer: A) A technique to convert high-level language to machine code before execution

Q11. What is process loading in an operating system?
A) Transferring executable code from disk to main memory
B) Translating source code into machine code
C) Creating new files in memory
D) Debugging and testing a program
Answer: A) Transferring executable code from disk to main memory

Q12. Which component is responsible for linking object code and required libraries?
A) Compiler
B) Linker
C) Loader
D) Debugger
Answer: B) Linker

Q13. What is dynamic linking?
A) Loading all libraries at compile time
B) Linking libraries to a program at runtime
C) Executing code without linking
D) Using only built-in libraries
Answer: B) Linking libraries to a program at runtime

Q14. Which of the following statements about static linking is TRUE?
A) All external library functions are embedded in the final executable
B) Libraries are linked at runtime
C) It reduces the size of the executable file
D) It allows updating libraries without recompiling the program
Answer: A) All external library functions are embedded in the final executable

Q15. Which type of linking uses shared libraries that can be updated without recompiling programs?
A) Static linking
B) Dynamic linking
C) Absolute linking
D) Direct linking
Answer: B) Dynamic linking

Q16. What is call by value in parameter passing?
A) The actual variable is modified inside the function
B) A copy of the variable is passed to the function
C) The memory address of the variable is passed
D) The function does not accept parameters
Answer: B) A copy of the variable is passed to the function

Q17. What is the main disadvantage of call by reference?
A) More memory is used
B) The original data may be modified accidentally
C) The function does not return a value
D) It cannot be used with object-oriented languages
Answer: B) The original data may be modified accidentally

Q18. Which type of binding occurs at runtime?
A) Early binding
B) Static binding
C) Late binding
D) Pre-binding
Answer: C) Late binding

Q19. Which type of binding is associated with method overloading?
A) Early binding
B) Late binding
C) Dynamic binding
D) Compile-time binding
Answer: A) Early binding

Q20. Which of the following is an example of dynamic binding?
A) Function overloading
B) Operator overloading
C) Virtual functions in C++
D) Function inlining
Answer: C) Virtual functions in C++

Q21. Which storage class in C++ defines a variable that retains its value between function calls?
A) Auto
B) Register
C) Static
D) External
Answer: C) Static

Q22. Which storage class is used for global variables?
A) Auto
B) Static
C) Extern
D) Register
Answer: C) Extern

Q23. What is the purpose of the register storage class?
A) To store data in the CPU register for fast access
B) To allocate memory on the heap
C) To make variables global
D) To store constant values
Answer: A) To store data in the CPU register for fast access

Q24. Which of the following memory locations is used for dynamic memory allocation?
A) Stack
B) Heap
C) Register
D) Data segment
Answer: B) Heap

Q25. Which memory segment stores global and static variables?
A) Stack
B) Heap
C) Data segment
D) Code segment
Answer: C) Data segment

Q26. Which of the following is NOT a memory allocation function in C++?
A) malloc()
B) new
C) delete
D) allocate()
Answer: D) allocate()

Q27. What happens when an object is created using the new keyword?
A) Memory is allocated on the stack
B) Memory is allocated on the heap
C) Memory is allocated in the code segment
D) Memory is not allocated
Answer: B) Memory is allocated on the heap

Q28. What is the purpose of a destructor in C++?
A) To create an object
B) To deallocate memory when an object is deleted
C) To initialize an object
D) To overload a function
Answer: B) To deallocate memory when an object is deleted

Q29. Which operator is used to deallocate memory in C++?
A) free
B) new
C) delete
D) remove
Answer: C) delete

Q30. What is a memory leak?
A) When a program uses less memory than required
B) When allocated memory is not freed properly
C) When memory allocation fails
D) When memory is shared between functions
Answer: B) When allocated memory is not freed properly

Unit - 5

  1. What is a data structure?
    a) A way to store and organize data
    b) A programming language
    c) A type of database
    d) A sorting algorithm
    Answer: a) A way to store and organize data

  2. Which of the following is a linear data structure?
    a) Graph
    b) Tree
    c) Stack
    d) Hash Table
    Answer: c) Stack

  3. Which of the following is a non-linear data structure?
    a) Queue
    b) Stack
    c) Tree
    d) Array
    Answer: c) Tree

  4. What is the primary purpose of a data structure?
    a) To manage memory
    b) To process large datasets efficiently
    c) To organize and store data effectively
    d) To compile programs
    Answer: c) To organize and store data effectively

  5. Which data structure allows random access to its elements?
    a) Stack
    b) Queue
    c) Array
    d) Linked List
    Answer: c) Array

  6. Which data structure follows LIFO (Last In, First Out)?
    a) Queue
    b) Stack
    c) Linked List
    d) Tree
    Answer: b) Stack

  7. In which data structure is deletion only allowed at one end and insertion at another?
    a) Stack
    b) Queue
    c) Linked List
    d) Graph
    Answer: b) Queue

  8. What is the main advantage of a linked list over an array?
    a) Faster access time
    b) Uses less memory
    c) Dynamic memory allocation
    d) More efficient sorting
    Answer: c) Dynamic memory allocation

  9. Which data structure is best suited for recursion?
    a) Queue
    b) Stack
    c) Graph
    d) Array
    Answer: b) Stack

  10. Which of the following operations is not possible in constant time O(1) in an array?
    a) Accessing an element
    b) Deleting an element at a given index
    c) Inserting an element at the end
    d) Updating an element
    Answer: b) Deleting an element at a given index

  11. The worst-case time complexity of Quick Sort is:
    a) O(n)
    b) O(n log n)
    c) O(n²)
    d) O(log n)
    Answer: c) O(n²)

  12. Which sorting algorithm is best for small datasets?
    a) Merge Sort
    b) Bubble Sort
    c) Quick Sort
    d) Radix Sort
    Answer: b) Bubble Sort

  13. Which sorting algorithm is in-place and stable?
    a) Merge Sort
    b) Quick Sort
    c) Insertion Sort
    d) Heap Sort
    Answer: c) Insertion Sort

  14. The time complexity of inserting an element at the end of an array (assuming space is available) is:
    a) O(1)
    b) O(n)
    c) O(log n)
    d) O(n²)
    Answer: a) O(1)

  15. The best case time complexity of Bubble Sort is:
    a) O(n²)
    b) O(n log n)
    c) O(n)
    d) O(1)
    Answer: c) O(n)

  16. Which of the following linked lists allows traversing in both directions?
    a) Singly Linked List
    b) Circular Linked List
    c) Doubly Linked List
    d) Stack
    Answer: c) Doubly Linked List

  17. The time complexity to delete a node from a singly linked list is:
    a) O(1)
    b) O(n)
    c) O(log n)
    d) O(n²)
    Answer: b) O(n)

  18. Which linked list node contains a pointer that connects the last node to the first node?
    a) Singly Linked List
    b) Doubly Linked List
    c) Circular Linked List
    d) Stack
    Answer: c) Circular Linked List

  19. What is the primary advantage of a doubly linked list over a singly linked list?
    a) Requires less memory
    b) Easier backward traversal
    c) Faster searching
    d) Uses array indexing
    Answer: b) Easier backward traversal

  20. The time complexity of insertion at the beginning in a linked list is:
    a) O(1)
    b) O(n)
    c) O(n log n)
    d) O(n²)
    Answer: a) O(1)

  21. Which of the following data structures is used for undo/redo operations?
    a) Queue
    b) Stack
    c) Linked List
    d) Hash Table
    Answer: b) Stack

  22. Which queue allows insertion and deletion at both ends?
    a) Priority Queue
    b) Circular Queue
    c) Deque
    d) Simple Queue
    Answer: c) Deque

  23. What is the time complexity of dequeue operation in a queue?
    a) O(1)
    b) O(n)
    c) O(log n)
    d) O(n²)
    Answer: a) O(1)

  24. Which data structure can be used to implement recursion?
    a) Queue
    b) Stack
    c) Graph
    d) Hash Table
    Answer: b) Stack

  25. Which of the following is not an application of stacks?
    a) Function calls
    b) Backtracking
    c) CPU scheduling
    d) Undo operations
    Answer: c) CPU scheduling

  26. A binary search tree (BST) follows which property?
    a) Left subtree has smaller values, right has larger
    b) Right subtree has smaller values, left has larger
    c) All nodes have at most two children
    d) It is a balanced tree
    Answer: a) Left subtree has smaller values, right has larger

  27. Which tree balances itself to ensure O(log n) operations?
    a) Binary Search Tree
    b) AVL Tree
    c) Complete Binary Tree
    d) Graph
    Answer: b) AVL Tree

  28. Dijkstra’s algorithm is used for:
    a) Finding shortest path
    b) Sorting an array
    c) Checking tree balance
    d) Graph coloring
    Answer: a) Finding shortest path

  29. The best hashing function should minimize:
    a) Collisions
    b) Comparisons
    c) Space complexity
    d) Execution time
    Answer: a) Collisions

  30. A Max Heap always has:
    a) The largest element at the root
    b) The smallest element at the root
    c) Elements stored in sorted order
    d) Random arrangement
    Answer: a) The largest element at the root

Unit - 6

Q1. What is an algorithm?
A) A programming language
B) A step-by-step procedure to solve a problem
C) A high-level data structure
D) A mathematical formula
Answer: B) A step-by-step procedure to solve a problem

Q2. Which of the following is NOT a characteristic of a good algorithm?
A) It should be well-defined
B) It should have infinite steps
C) It should have an input and output
D) It should be efficient
Answer: B) It should have infinite steps

Q3. The correctness of an algorithm means that:
A) It produces the expected output for all valid inputs
B) It runs in the least possible time
C) It always runs in constant time
D) It uses the smallest possible memory
Answer: A) It produces the expected output for all valid inputs

Q4. Which of the following is NOT an approach to designing algorithms?
A) Divide and conquer
B) Dynamic programming
C) Randomized guessing
D) Greedy algorithms
Answer: C) Randomized guessing

Q5. What is the first step in algorithm design?
A) Writing code
B) Understanding the problem
C) Choosing a programming language
D) Analyzing space complexity
Answer: B) Understanding the problem

Q6. Which of the following best describes the time complexity of an algorithm?
A) The amount of time required to execute a program
B) The time required to compile a program
C) The relationship between input size and execution time
D) The amount of memory used by an algorithm
Answer: C) The relationship between input size and execution time

Q7. Which of the following functions grows the fastest?
A) log(n)
B) n
C) n log(n)
D) 2^n
Answer: D) 2^n

Q8. If an algorithm takes O(n²) time, how does the running time change when the input size doubles?
A) It remains the same
B) It doubles
C) It quadruples
D) It increases exponentially
Answer: C) It quadruples

Q9. If an algorithm has a time complexity of O(1), what does it mean?
A) Its execution time depends on the input size
B) It runs in constant time, independent of input size
C) It runs faster on smaller inputs
D) It requires linear time to execute
Answer: B) It runs in constant time, independent of input size

Q10. Which complexity class represents the worst possible performance?
A) O(log n)
B) O(n)
C) O(n²)
D) O(2^n)
Answer: D) O(2^n)

Q11. What does Big-O notation describe?
A) Best-case performance of an algorithm
B) Average-case performance of an algorithm
C) Worst-case performance of an algorithm
D) The programming language used to implement the algorithm
Answer: C) Worst-case performance of an algorithm

Q12. What is the Big-O notation for binary search?
A) O(1)
B) O(n)
C) O(log n)
D) O(n²)
Answer: C) O(log n)

Q13. Which notation represents the best-case scenario of an algorithm?
A) O(n)
B) Θ(n)
C) Ω(n)
D) O(log n)
Answer: C) Ω(n)

Q14. If an algorithm has a complexity of O(n log n), which algorithm could it be?
A) Bubble sort
B) Merge sort
C) Linear search
D) Fibonacci sequence generation
Answer: B) Merge sort

Q15. Which notation represents both the lower and upper bounds of an algorithm’s complexity?
A) O(n)
B) Ω(n)
C) Θ(n)
D) O(2^n)
Answer: C) Θ(n)

Q16. What is recursion?
A) A function that calls itself
B) A function that runs in an infinite loop
C) A function that executes multiple threads
D) A function that does not return a value
Answer: A) A function that calls itself

Q17. What is the base case in recursion?
A) The smallest instance of the problem where recursion stops
B) The first function call in recursion
C) The last function executed in recursion
D) A case where recursion runs infinitely
Answer: A) The smallest instance of the problem where recursion stops

Q18. Which of the following algorithms uses backtracking?
A) Merge sort
B) Quick sort
C) N-Queens problem
D) Binary search
Answer: C) N-Queens problem

Q19. Which of the following is NOT a problem solved using backtracking?
A) Sudoku solver
B) Hamiltonian cycle
C) Fibonacci sequence
D) Knight’s tour
Answer: C) Fibonacci sequence

Q20. What is a disadvantage of recursion?
A) It cannot be implemented in C++
B) It uses more memory due to function calls
C) It runs faster than iterative solutions
D) It does not allow nested function calls
Answer: B) It uses more memory due to function calls

Q21. What is dynamic programming?
A) A method for solving problems by combining solutions to subproblems
B) A way of writing programs dynamically
C) A strategy for parallel computing
D) A method to reduce memory consumption
Answer: A) A method for solving problems by combining solutions to subproblems

Q22. Which of the following problems can be solved using dynamic programming?
A) Fibonacci series
B) Linear search
C) Bubble sort
D) Insertion sort
Answer: A) Fibonacci series

Q23. What is memoization in dynamic programming?
A) Storing computed results to avoid duplicate calculations
B) Sorting data before processing
C) Using additional loops for efficiency
D) Decreasing the size of input data
Answer: A) Storing computed results to avoid duplicate calculations

Q24. What is the main advantage of dynamic programming over recursion?
A) Uses less memory
B) Reduces duplicate computations
C) Works only with sorting problems
D) Runs in constant time
Answer: B) Reduces duplicate computations

Q25. Which approach is used in dynamic programming?
A) Bottom-up
B) Top-down
C) Both A and B
D) None of the above
Answer: C) Both A and B

Q26. What is the greedy algorithm strategy?
A) Making the best choice at each step without considering future consequences
B) Splitting a problem into smaller subproblems
C) Using recursion for solving problems
D) Checking all possible solutions before selecting one
Answer: A) Making the best choice at each step without considering future consequences

Q27. Which problem can be solved using a greedy algorithm?
A) Fibonacci series
B) Minimum spanning tree
C) Merge sort
D) Tower of Hanoi
Answer: B) Minimum spanning tree

Q28. Which of the following is NOT solved using a greedy approach?
A) Kruskal’s algorithm
B) Dijkstra’s shortest path
C) Huffman coding
D) Matrix chain multiplication
Answer: D) Matrix chain multiplication

Q29. Which data structure is commonly used in a greedy algorithm?
A) Stack
B) Queue
C) Heap
D) Linked list
Answer: C) Heap

Q30. What is a major disadvantage of greedy algorithms?
A) They always give optimal solutions
B) They require additional memory
C) They may not always provide the best solution
D) They are inefficient
Answer: C) They may not always provide the best solution

Tags

Post a Comment

0Comments
Post a Comment (0)
Let's Chat
Let's Chat

Let's Make Magic Happen! ✨

Drop us a message or join our whatsapp group