LEARNING IS A JOURNEY IB REVISION - SAMPLE QUESTIONS
SAMPLE QUESTIONS FOR QUICK REVISION
MIXED SAMPLE QUESTIONS 1
Explain the difference between a compiler and an interpreter.
Discuss the impact of the Internet on society and the economy.
What is the purpose of an operating system and give an example.
Discuss the differences between serial and parallel processing.
Explain the difference between lossless and lossy data compression.
Describe the advantages and disadvantages of using cloud computing.
Discuss the ethical, social and professional issues associated with using technology.
Explain the role of algorithms in computer science and provide an example.
What is the purpose of a database and how is it used in real-world applications?
Describe the steps involved in software development and explain the role of each stage.
A compiler is a program that converts source code into machine code before the program is executed. An interpreter, on the other hand, executes source code line by line and is usually slower than compiled code.
The Internet has had a significant impact on society by allowing for greater access to information, facilitating communication and collaboration, and creating new business opportunities. It has also led to changes in the economy by enabling e-commerce, allowing remote work, and promoting innovation.
An operating system is a software that manages the resources of a computer and provides a platform for other software to run. Examples include Windows, macOS, and Linux.
Serial processing involves completing tasks one after another, while parallel processing involves completing tasks simultaneously. Serial processing is simpler and requires less hardware, but parallel processing is faster and more efficient.
Lossless data compression involves reducing the size of a file without losing any information, while lossy data compression involves removing some information to reduce the file size. Lossless compression is better for important data, while lossy compression is used for audio and video files where some loss of quality is acceptable.
Cloud computing offers benefits such as increased accessibility, scalability, and reduced costs. However, it also raises concerns such as data security, privacy, and vendor lock-in.
The use of technology raises ethical, social, and professional issues such as data privacy, cyber bullying, and digital divide. Computer scientists have a responsibility to consider the implications of their work and to act in the public interest.
An algorithm is a set of steps that solve a problem in a specific, effective, and repeatable way. Algorithms are used in many areas of computer science, such as sorting data, searching databases, and optimizing solutions.
A database is a collection of data organized in a way that enables efficient access and manipulation. Databases are used in a wide range of applications, such as online shopping, social media, and financial systems.
Software development involves several stages, including requirements gathering, design, implementation, testing, and maintenance. Each stage is important in ensuring that the final product meets the needs of users, is reliable, and can be maintained over time.
STACKS AND QUEUES
What is a stack and how does it differ from a queue in terms of data storage and retrieval?
What is the Last In First Out (LIFO) principle in relation to stacks?
How can you implement a stack using an array or linked list in computer science?
What is the difference between a stack overflow and a stack underflow error?
What is the First In First Out (FIFO) principle in relation to queues?
How can you implement a queue using a linked list in computer science?
What is a priority queue and how does it differ from a normal queue?
Can a stack or a queue be used to solve the Tower of Hanoi problem, and why?
A stack is a linear data structure that operates on the principle of Last In First Out (LIFO). This means that the last item added to the stack will be the first item to be removed. On the other hand, a queue is a linear data structure that operates on the principle of First In First Out (FIFO), meaning that the first item added to the queue will be the first item to be removed.
The Last In First Out (LIFO) principle means that the last item added to the stack will be the first item to be removed. This is in contrast to a queue, where the first item added will be the first item removed.
A stack can be implemented using an array by keeping track of the top index of the stack and using it to determine where to add or remove elements. Alternatively, a stack can be implemented using a linked list, where each node in the list represents an element in the stack and the top of the stack is represented by the head of the linked list.
A stack overflow error occurs when the stack runs out of memory and can no longer allocate space for new elements, while a stack underflow error occurs when an attempt is made to remove an element from an empty stack.
The First In First Out (FIFO) principle means that the first item added to the queue will be the first item to be removed. This is in contrast to a stack, where the last item added will be the first item removed.
A queue can be implemented using a linked list by keeping track of both the head and tail of the queue. The head of the queue represents the first item to be removed, while the tail represents the last item to be added.
A priority queue is a type of queue where each element is assigned a priority and the element with the highest priority is removed first, regardless of the order in which it was added. This is in contrast to a normal queue, where the first item added is the first item to be removed.
A stack can be used to solve the Tower of Hanoi problem by pushing and popping discs onto and off of the stack. On the other hand, a queue can also be used to solve the problem by enqueuing and dequeuing intermediate states of the problem. However, a stack is often the preferred data structure for solving the Tower of Hanoi problem as it allows for a more intuitive and efficient solution.
What is the difference between a comparison-based and non-comparison-based sorting algorithm?
How does the Bubble Sort algorithm work and what is its principle?
How does the Quick Sort algorithm work and what is its basic idea?
What is the main difference between the Merge Sort and Insertion Sort algorithms?
How does the Selection Sort algorithm work and what is its basic principle?
Can you explain the concept of divide and conquer in relation to sorting algorithms?
How does the Heap Sort algorithm work and what is its basic idea?
Compare and contrast the Bubble Sort and Merge Sort algorithms in terms of time complexity, stability, and ease of implementation.
A comparison-based sorting algorithm is a type of sorting algorithm that uses comparisons between elements in an array to determine their order. Non-comparison-based sorting algorithms, on the other hand, do not rely on comparisons between elements and instead use other techniques, such as counting, to sort an array.
The Bubble Sort algorithm works by iterating through an array and comparing adjacent elements, swapping them if they are in the wrong order. This process is repeated until the array is sorted. The basic principle of the Bubble Sort algorithm is to continuously swap adjacent elements until the largest elements "bubble" to the end of the array.
The Quick Sort algorithm is a divide-and-conquer algorithm that works by selecting a pivot element from an array and partitioning the other elements into two sub-arrays, according to whether they are less than or greater than the pivot. The sub-arrays are then sorted recursively. The basic idea of Quick Sort is to divide the array into smaller sub-arrays and then sort those sub-arrays.
The main difference between the Merge Sort and Insertion Sort algorithms is that Merge Sort is a divide-and-conquer algorithm, while Insertion Sort is a simple sorting algorithm. Merge Sort divides an array into smaller sub-arrays and sorts them, while Insertion Sort sorts an array by iteratively inserting elements in their correct position.
The Selection Sort algorithm works by repeatedly finding the minimum element from the unsorted part of the array and swapping it with the first element in the unsorted part. The basic principle of the Selection Sort algorithm is to continuously find the minimum element from the unsorted part of the array and place it at the beginning.
Divide and conquer is a technique used in algorithms to solve problems by breaking them down into smaller sub-problems and solving each sub-problem individually. In the context of sorting algorithms, divide and conquer refers to breaking an array down into smaller sub-arrays and sorting each sub-array individually before combining them back into a single sorted array.
The Heap Sort algorithm works by creating a binary heap data structure and using it to sort an array. The basic idea of Heap Sort is to continuously extract the maximum element from the binary heap and place it at the end of the array, until all elements have been extracted and the array is sorted.
The Bubble Sort algorithm is a simple and straightforward sorting algorithm, but it is not very efficient, especially for large arrays. The time complexity of Bubble Sort in the worst case is O(n^2), where n is the number of elements in the array. On the other hand, Merge Sort is a more efficient algorithm with a time complexity of O(nlogn) in the worst case. However, Merge Sort is more complex to implement than Bubble Sort. In terms of stability, Bubble Sort is a stable sorting algorithm, while Merge Sort is also a stable sorting algorithm.
What is a binary tree and what are its main components?
What is the difference between a binary tree and a binary search tree?
How do you perform a pre-order traversal on a binary tree?
What is the difference between a full binary tree and a complete binary tree?
How is the height of a binary tree calculated and why is it important in determining the efficiency of certain operations on the tree?
A binary tree is a tree data structure in which each node can have at most two children, referred to as the left child and the right child. The main components of a binary tree are the nodes and the edges connecting them. Each node in a binary tree contains a value and references to its left and right children, if they exist.
A binary search tree is a type of binary tree in which the value of each node is greater than or equal to all values in its left subtree and less than or equal to all values in its right subtree. In other words, the values in the left subtree are always smaller than the value of the node, while the values in the right subtree are always greater. A binary tree, on the other hand, does not have this restriction on the values of its nodes.
A pre-order traversal of a binary tree involves visiting the root node first, then visiting the left subtree, and finally visiting the right subtree. This process is repeated recursively for each node in the tree. The pre-order traversal is often used to construct a copy of the binary tree or to perform some operation on each node in the tree.
A full binary tree is a binary tree in which every node has either zero or two children. In other words, there are no nodes in the tree with only one child. A complete binary tree, on the other hand, is a binary tree in which every level of the tree is completely filled, except for the last level, which is filled from left to right.
The height of a binary tree is defined as the number of edges from the root node to the deepest leaf node. The height of a binary tree is an important factor in determining the efficiency of certain operations on the tree, such as searching and inserting. A binary tree with a smaller height will generally have faster search and insertion times compared to a binary tree with a larger height.
What is the role of an operating system in managing the resources of a computer?
What are the different types of operating systems and how do they differ in terms of their functionality?
How does the operating system manage processes and allocate CPU time to each process?
What is the role of the operating system in memory management, and how does it ensure that programs can access the required amount of memory efficiently?
How does the operating system handle input and output operations, and what role does it play in managing devices such as printers and storage devices?
What is the role of the operating system in providing a user interface, and what are some common user interface features in operating systems?
What is the role of the operating system in security, and what are some common security features in operating systems?
What is the role of the operating system in file management, and how does it support the creation, modification, and deletion of files and directories?
How does the operating system use time slicing to allocate CPU time to multiple processes, and what is the purpose of time slicing in operating systems?
What is the purpose of virtual memory and how does the operating system manage virtual memory to ensure that programs have access to the memory they need to run?
The operating system plays a crucial role in managing the resources of a computer, such as the CPU, memory, storage devices, and input/output devices. It allocates these resources to different programs and processes, ensuring that they can run smoothly and efficiently. This includes managing the allocation of memory, scheduling CPU time, and managing the input and output operations of devices.
There are several types of operating systems, including single-user, multi-user, real-time, and embedded systems. Single-user systems are designed for use by a single user, while multi-user systems allow multiple users to access the computer simultaneously. Real-time operating systems are designed to respond to events within a specific time frame, while embedded systems are used in devices such as smartphones, televisions, and appliances.
The operating system manages processes by creating a process control block (PCB) for each process and allocating CPU time to each process using a scheduling algorithm. The operating system periodically switches between processes to ensure that each process gets a fair share of CPU time. The operating system also manages the execution of processes, including starting and stopping processes, and managing their execution status.
The operating system is responsible for managing memory and ensuring that programs have access to the memory they need to run. It uses techniques such as paging and segmentation to manage memory allocation and ensure efficient use of memory. The operating system also implements virtual memory, which allows programs to access more memory than is physically available by temporarily swapping data between the hard disk and physical memory.
The operating system handles input and output operations by providing an interface between the program and the device. This allows the program to send commands to the device and receive data from it, without having to deal with the underlying hardware. The operating system also manages the allocation of devices, such as printers and storage devices, ensuring that multiple programs can access them simultaneously.
The operating system provides a user interface, which is the interface between the user and the computer. The user interface can include a graphical user interface (GUI) or a command-line interface (CLI). The GUI is a visual interface that allows users to interact with the computer using icons, windows, and other graphical elements. The CLI is a text-based interface that allows users to enter commands directly into the computer.
The operating system plays a crucial role in security by implementing security measures such as access controls, file permissions, and firewalls. Access controls are used to control who can access files and directories, while file permissions are used to control what a user can do with a file or directory. Firewalls are used to prevent unauthorized access to the computer from the network.
The operating system is responsible for managing the file system, which is the way that files and directories are organized on the computer. This includes creating, modifying, and deleting files and directories, as well as managing the storage and retrieval of files. The operating system also provides a set of APIs (Application Programming Interfaces) that programs can use to access the file system and perform file-related operations.
Time slicing is a technique used by the operating system to allocate CPU time to multiple processes. The operating system periodically switches between processes, allowing each process to run for a short time slice before switching to the next process. This allows multiple processes to run concurrently and ensures that each process gets a fair share of CPU time.
Virtual memory is a technique used by the operating system to provide programs with access to more memory than is physically available. When a program needs more memory than is available, the operating system temporarily swaps data between the hard disk and physical memory, allowing the program to continue running.
What is the difference between RAM and ROM?
What is volatile memory and why is it called so?
What are the types of non-volatile memory?
What is cache memory and what is its purpose?
Explain the role of virtual memory in computer systems.
What is the purpose of paging in virtual memory management?
What is the difference between a solid-state drive and a hard disk drive?
What is cloud storage and how does it work?
What is the difference between sequential access and random access memory?
How does the memory hierarchy affect the performance of a computer system?
RAM (Random Access Memory) is a type of volatile memory that stores data temporarily, allowing the processor to quickly access and modify it as needed. ROM (Read Only Memory) is a type of non-volatile memory that stores data permanently and cannot be modified by the processor.
Volatile memory is called so because its contents are lost when the power is turned off. RAM is a type of volatile memory.
Non-volatile memory includes types such as ROM, EPROM, EEPROM, and flash memory. These types of memory retain their contents even when the power is turned off.
Cache memory is a type of high-speed memory that is used to store frequently accessed data so that the processor can quickly access it. Its purpose is to reduce the average time to access data from the main memory, improving the overall performance of the computer system.
Virtual memory is a technique that allows a computer system to use more memory than it physically has by temporarily transferring parts of the contents of RAM to a hard disk. The operating system uses virtual memory to extend the amount of accessible memory, by temporarily storing inactive data in the hard disk. This allows the system to run larger applications or multiple applications simultaneously.
Paging is a memory management technique used in virtual memory systems. It allows the system to break down data stored in RAM into smaller units called pages, which can be stored and retrieved individually. This allows the operating system to efficiently manage the available memory by swapping pages between RAM and the hard disk as needed. The purpose of paging is to increase the amount of available memory for the system, by using the hard disk as a virtual memory extension.
A solid-state drive (SSD) is a type of storage device that uses flash memory to store data, while a hard disk drive (HDD) uses rotating disks to store data. SSDs are faster and more reliable, but also more expensive, while HDDs are slower but more affordable.
Cloud storage is a model of data storage where the digital data is stored in logical pools, with physical storage spread across multiple servers and locations. The data is stored on remote servers and can be accessed over the internet.
Sequential access memory stores data in a predetermined order, allowing for fast access to data stored in a contiguous location. Random access memory allows for the direct access of any memory location, making it faster for small data transfers, but slower for large sequential transfers.
The memory hierarchy affects the performance of a computer system because it determines the speed and accessibility of the various types of memory. Data stored in faster, smaller, and more expensive memory types can be accessed more quickly, while data stored in slower, larger, and less expensive memory types takes longer to access. This affects the overall performance of the system and the ability to run applications efficiently.
What is recursion and how does it differ from iteration?
What is the base case in a recursive function and why is it important?
How does recursion work in terms of function call stack and memory usage?
Can every problem be solved using recursion? Give an example where recursion is not the best solution.
What are some common examples of problems that can be solved using recursion?
In pseudocode show how you would implement a recursive function to calculate the sum of all elements in an array?
In pseudocode show how you would implement a recursive function to find the maximum value in an array?
In pseudocode show how you would implement a recursive function to find the nth Fibonacci number?
Recursion is a technique in computer programming where a function calls itself in order to solve a problem. It differs from iteration, which uses loops, by breaking a problem down into smaller subproblems and solving them recursively.
The base case in a recursive function is a stopping condition that prevents the function from infinitely calling itself. It is important because it provides an exit point for the recursion, allowing the function to return a result and prevent an infinite loop.
Recursion works by using a function call stack. Each time a recursive function is called, a new stack frame is created and added to the top of the stack. When the base case is reached, the stack frames are popped off and the results are combined to form the final answer. Memory usage in a recursive function is proportional to the maximum number of function calls made before the base case is reached.
Not every problem can be solved using recursion. For example, problems that require the use of a loop or require a large amount of data to be processed may not be well suited for recursion.
Common examples of problems that can be solved using recursion include: finding the factorial of a number, calculating the nth Fibonacci number, traversing a tree or graph structure, and solving the tower of Hanoi puzzle.
6: In pseudocode show how you would implement a recursive function to calculate the sum of all elements in an array? function sumArray(array, n): if n == 0: return array else: return array[n] + sumArray(array, n-1)
7: In pseudocode show how you would implement a recursive function to find the maximum value in an array? function findMax(array, n): if n == 0: return array else: max = findMax(array, n-1) if array[n] > max: return array[n] else: return max
8: In pseudocode show how you would implement a recursive function to find the nth Fibonacci number? function fib(n): if n <= 0: return 0 elif n == 1: return 1 else: return fib(n-1) + fib(n-2)
Write pseudocode to find the average of three numbers.
Write pseudocode to find the factorial of a given number.
Write pseudocode to print all the prime numbers up to a given limit.
Write pseudocode to check if a given year is a leap year or not.
Write pseudocode to sort a given array of integers in ascending order.
Write pseudocode to find the greatest common divisor of two numbers.
Write pseudocode to find the largest number in an array of integers.
Write pseudocode to convert a decimal number to binary.
Write pseudocode to find the average of three numbers. INPUT: num1, num2, num3 sum = num1 + num2 + num3 average = sum / 3 OUTPUT: average
Write pseudocode to find the factorial of a given number. INPUT: num factorial = 1 FOR i = 1 to num factorial = factorial * i NEXT i OUTPUT: factorial
Write pseudocode to print all the prime numbers up to a given limit. INPUT: limit FOR num = 2 to limit isPrime = true FOR i = 2 to (num-1) IF (num MOD i) == 0 isPrime = false EXIT FOR END IF NEXT i IF isPrime OUTPUT num END IF NEXT num
Write pseudocode to check if a given year is a leap year or not. INPUT: year IF (year MOD 400 == 0) OR ((year MOD 4 == 0) AND (year MOD 100 != 0)) isLeap = true ELSE isLeap = false END IF OUTPUT: isLeap
Write pseudocode to sort a given array of integers in ascending order. INPUT: array of size n FOR i = 0 to (n-1) FOR j = 0 to (n-i-1) IF array[j] > array[j+1] temp = array[j] array[j] = array[j+1] array[j+1] = temp END IF NEXT j NEXT i OUTPUT: array
Write pseudocode to find the greatest common divisor of two numbers. INPUT: num1, num2 WHILE num2 != 0 temp = num2 num2 = num1 MOD num2 num1 = temp END WHILE gcd = num1 OUTPUT: gcd
Write pseudocode to find the largest number in an array of integers. INPUT: array of size n largest = array FOR i = 1 to (n-1) IF array[i] > largest largest = array[i] END IF NEXT i OUTPUT: largest
Write pseudocode to convert a decimal number to binary. INPUT: decimal binary = "" WHILE decimal > 0 binary = (decimal MOD 2) + binary decimal = decimal DIV 2 END WHILE OUTPUT: binary