Explain the role of the "C" in ACID properties and its significance in database transactions.
- Atomicity
- Data Consistency
- Durability
- Isolation
The "C" in ACID stands for Atomicity. This property ensures that either all operations within a transaction are completed successfully or none are applied at all. It helps in maintaining data integrity and ensuring that transactions are either fully executed or not executed at all.
Which searching algorithm requires the elements to be in sorted order?
- Binary search
- Depth-first search
- Hashing
- Linear search
Binary search requires the elements to be in sorted order because it uses the principle of divide and conquer, comparing the middle element and eliminating half of the search space in each step.
Explain the concept of a spanning tree in graph theory and its significance in network design.
- A spanning tree is a subset of edges that connects all vertices in a graph without forming any cycles.
- It ensures there are no disconnected nodes in the network.
- Spanning trees minimize the number of edges in a graph.
- They simplify network design by eliminating redundant connections and ensuring network connectivity with minimal resources.
In graph theory, a spanning tree is vital for network design as it forms the backbone of connectivity without creating loops or redundancies. By spanning all nodes with the least number of edges possible, spanning trees optimize network resources and ensure efficient communication paths.
The process of removing a node from a linked list without needing to traverse from the beginning is called ___________.
- Cut, Erase
- Deletion, Removal
- Detach, Delete
- Unlink, Extract
The process of removing a node from a linked list without traversing from the beginning is called "unlinking" or "extracting" the node. This involves updating the pointers of the surrounding nodes to skip the removed node.
In the ___________ design pattern, a chain of processing objects is created where each object contains logic to determine if it can process the request.
- Factory Pattern
- Chain of Responsibility Pattern
- Strategy Pattern
- Decorator Pattern
The correct option is the Chain of Responsibility Pattern. This pattern creates a chain of objects, each capable of processing a request or passing it to the next object in the chain.
In merge sort, the merge operation combines two ___________ arrays into a single sorted array.
- Equal-sized
- Sorted
- Subarray
- Unsorted
In merge sort, the merge operation combines two sorted arrays into a single sorted array. This is a crucial step in the merge sort algorithm, where the sorted subarrays from the divide step are merged back together to create a larger sorted array. The merging process compares elements from both arrays and arranges them in ascending or descending order, depending on the sorting order specified.
You're developing a web application where users need to upload images. How would you validate the file type and size using JavaScript?
- Use File API to check file size
- Use FileReader API to read file metadata
- Use accept attribute in tag
- Use typeof operator to check file type
Using the accept attribute in the tag allows specifying the allowed file types (MIME types) that users can upload. This provides client-side validation to ensure that only files of specified types are accepted. The File API, on the other hand, allows accessing file metadata, including size. Using typeof is not suitable for file type validation. The FileReader API is used to read file content, not metadata.
Docker uses ________ files to define the configuration of a containerized application.
- .yaml
- .json
- .cfg
- .dockerfile
The correct option is ".dockerfile." Docker uses Dockerfiles, which are plain text configuration files with a specific syntax, to define the steps needed to create a container image. These files specify the base image, environment variables, dependencies, and commands to run when the container starts. Dockerfiles are essential for building reproducible and version-controlled containerized applications, making it easier to manage and scale container deployments.
When is it preferable to use merge sort over quicksort?
- Input size
- Memory usage
- Stability of sorting
- Time complexity
Merge sort is preferable over quicksort when dealing with large input sizes due to its guaranteed O(n log n) time complexity, which is advantageous over quicksort's worst-case O(n^2) time complexity.
Which type of linked list is best suited for implementing a stack?
- Array-based list
- Circular linked list
- Doubly linked list
- Singly linked list
A singly linked list is best suited for implementing a stack because it only requires a pointer to the top element, allowing for efficient insertion and removal operations at the top of the stack.