Computer science Quiz: Test Your Knowledge

Welcome to the ultimate challenge! If you think you know everything about computer science , this is your chance to prove it. Take the quiz below to test your knowledge, and don’t forget to share your score when you finish!

 

Results

Congratulations, your knowledge is tack sharp!

Better luck next time!

#1. In memory management, which region of a process’s memory is used for dynamic allocation and must be manually managed by the programmer in languages like C?

The heap is a dedicated segment of computer memory used for dynamic allocation during a program’s execution. Unlike the stack, which manages local variables automatically, heap memory must be manually requested and released by developers using specific commands. This flexibility allows for large or varying data structures, but improper handling can lead to issues like memory leaks or program crashes if resources are not freed.

#2. Which software architectural style defines a set of constraints for creating web services, typically using a stateless communication protocol and standard HTTP methods?

Representational State Transfer, or REST, is an architectural style used in web development. It was introduced by Roy Fielding in 2000. REST utilizes standard HTTP methods like GET, POST, PUT, and DELETE to manage data. Because it is stateless, the server does not store client information between requests. This design improves scalability and performance by simplifying communication between diverse systems and various internet applications.

#3. In the Model-View-Controller (MVC) software architectural pattern, which component is primarily responsible for managing the data and business rules of the application?

The Model-View-Controller pattern organizes software by dividing responsibilities into three distinct parts. As the core component, the Model handles data storage and the logic governing how information changes. This separation allows developers to modify the user interface without altering the underlying data structures. By isolating business rules, the Model ensures that application data remains consistent and accessible regardless of how it is presented to users.

#4. Which transport layer protocol uses a three-way handshake (SYN, SYN-ACK, ACK) to establish a reliable connection between a client and a server?

The Transmission Control Protocol, known as TCP, is a core element of the internet protocol suite. It ensures reliable data delivery by establishing a formal connection through a three-way handshake. During this specific process, the client and server exchange synchronization and acknowledgment packets to confirm communication readiness. This mechanism prevents data loss and maintains the correct sequence of information during network transit.

#5. In software engineering, which creational design pattern is used to ensure that a class has only one instance and provides a global point of access to it?

The Singleton pattern restricts a class from having more than one instance. It is commonly used for managing shared resources like database connections or logging services. This pattern provides a controlled access point for all other components. While effective, it can complicate testing because it maintains a global state, which may lead to dependencies across different parts of an application architecture.

#6. In a hash table that utilizes an efficient hash function to minimize collisions, what is the average-case time complexity for looking up an element?

A hash table maps keys to specific indices in an array using a hash function. In an ideal scenario where the function distributes keys uniformly, each lookup requires only a single operation to locate the target data. This efficiency results in constant time complexity, denoted as O(1). While worst case scenarios can reach linear time if collisions occur, optimized designs prioritize direct access for speed.

#7. Which Boolean logic gate returns an output of 1 (true) if and only if its two inputs are different from each other?

The XOR gate, short for Exclusive OR, is a fundamental component in digital electronics and computer arithmetic. Unlike the standard OR gate, which yields true if at least one input is true, the XOR gate requires exactly one input to be high. This unique property makes it essential for half-adders and error detection circuits such as parity checks in data transmission systems.

#8. In operating systems memory management, what is the term for the fixed-size blocks of physical memory into which the physical address space is divided?

In modern computer architecture, physical memory is partitioned into equal segments called frames. These units work alongside pages, which are similarly sized blocks of logical memory used by software applications. When a program executes, the operating system maps virtual pages to available physical frames. This structured division ensures efficient data storage and retrieval while minimizing fragmentation within the hardware components.

#9. In compiler construction, which initial phase is responsible for converting a sequence of characters into a sequence of meaningful tokens?

The lexical analyzer serves as the primary stage in the compilation process by scanning raw source code characters. It identifies meaningful patterns called lexemes and converts them into symbolic tokens like keywords or mathematical operators. This automated phase simplifies the work of the subsequent syntax analyzer by removing unnecessary elements such as whitespace and comments from the original program input text.

#10. Which programming paradigm is characterized by the use of pure functions and the avoidance of side effects and mutable state?

Functional programming treats computation as the evaluation of mathematical functions. Pure functions always produce the same output for a given input without modifying any external data. This approach minimizes side effects, making code easier to test and debug. By using immutable data, programmers avoid unpredictable changes in state, a common source of complex errors in imperative software development environments.

#11. Which graph algorithm is used to find the shortest path from a single source vertex to all other vertices in a weighted graph with non-negative edge weights?

Dijkstra’s algorithm was conceived by computer scientist Edsger W. Dijkstra in 1956. It works by maintaining a set of visited vertices and their minimum distances from the start. This greedy approach efficiently finds optimal paths in networks like road maps or telecommunications. However, it cannot handle negative edge weights, which would require alternative methods like the Bellman-Ford algorithm to ensure accuracy.

#12. Which data structure follows the Last-In, First-Out (LIFO) principle and is commonly used for managing function calls in memory?

A stack is a fundamental data structure that operates on the Last-In, First-Out principle. This means the most recently added item is the first to be removed. In computer science, the call stack manages active functions by storing temporary data and return locations. When a function finishes, its related data is removed from the top to resume the previous task.

#13. Which SQL clause is used to filter the results of an aggregate function, such as SUM or COUNT, after the grouping of data has been performed?

The HAVING clause is a structural component of SQL used to filter result sets after aggregate functions process grouped data. Unlike the WHERE clause, which evaluates individual rows before they are grouped, HAVING acts on the results of operations like COUNT or SUM. This distinction is vital for complex database queries requiring specific conditions to be applied to summarized categories rather than raw records.

#14. Which protocol is responsible for translating human-readable domain names, such as example.com, into numerical IP addresses?

The Domain Name System, or DNS, acts as a directory for the internet by linking domain names to their specific IP addresses. Since computers communicate using numerical identifiers while humans prefer names, this protocol bridges the gap. When a user enters a web address, a DNS resolver queries multiple servers to find the correct destination, ensuring the browser can load the requested content efficiently.

#15. Which object-oriented programming concept refers to the practice of bundling data and the methods that operate on that data into a single unit?

Encapsulation is a fundamental principle of object-oriented programming that organizes code by grouping data and methods together within a class. This structure restricts direct access to specific components, protecting an object’s internal state from unintended interference. By hiding technical details and providing a controlled interface for interaction, encapsulation improves software security and makes large codebases easier for developers to maintain and update over time.

#16. Which sorting algorithm consistently maintains a worst-case time complexity of O(n log n) by recursively dividing the array into halves?

Merge sort is a classic divide and conquer algorithm developed by John von Neumann in 1945. It operates by repeatedly splitting an array into smaller halves until single elements remain. These pieces are then systematically merged back together in the correct order. This predictable structure ensures the algorithm maintains efficiency even when processing data that is already sorted or completely reversed.

#17. In process scheduling, which preemptive algorithm allocates a small, fixed time unit known as a time quantum to each task?

Round Robin is a fundamental scheduling technique used by operating systems to handle multiple processes fairly. It assigns a specific time slice, or quantum, to each task in a circular queue. When a process uses its allotted time, the scheduler preempts it and moves it to the back of the line. This method prevents any single task from monopolizing the central processing unit resources.

#18. In operating systems, what is the term for a situation where two or more processes are unable to proceed because each is waiting for the other to release a resource?

In computing, a deadlock occurs when multiple processes become trapped in a circular dependency while competing for shared resources such as memory or hardware components. This permanent blockage prevents further progress within the software system. It is frequently compared to a four-way traffic jam where no driver can move forward. Operating systems employ specific algorithms to identify, prevent, or recover from these resource management failures.

#19. In the context of database management, which ACID property ensures that all operations in a transaction are completed as a single unit or not at all?

Atomicity is a fundamental principle in database management systems ensuring that complex transactions are treated as indivisible units. If any single operation within a sequence fails, the entire transaction is canceled and the database returns to its original state. This all-or-nothing mechanism prevents partial updates, which would otherwise lead to data corruption or inconsistencies during critical tasks like electronic financial transfers.

#20. Which layer of the Open Systems Interconnection (OSI) model is responsible for logical addressing and routing data packets between different networks?

The Network Layer is the third level of the Open Systems Interconnection model. It manages data routing and logical addressing, primarily using the Internet Protocol. This layer determines the best physical path for data to travel across interconnected systems. Routers operate here to forward packets between different networks based on IP addresses, ensuring information reaches its intended destination efficiently across complex digital infrastructures.

#21. What is the Big O time complexity of the Binary Search algorithm for searching an element in a sorted array of size n in the worst-case scenario?

Binary search works by repeatedly dividing a sorted array in half. If the target value is less than the middle element, the search narrows to the lower half. Otherwise, it narrows to the upper half. This logarithmic progression reduces the number of comparisons compared to linear search. In the worst case scenario, the algorithm continues halving until the target is found or the search range becomes empty.

Previous
Finish

Leave a Reply

Your email address will not be published. Required fields are marked *