Algorithms And Flow Charts Flashcards
What is an algorithm?
A clear, step-by-step set of instructions used to solve a problem or complete a task.
What is a flowchart?
A visual representation of an algorithm using standard symbols to show the flow of control and logic.
What are the key symbols used in flowcharts?
• Terminator (Oval): Start/End
• Process (Rectangle): Task or instruction
• Decision (Diamond): Yes/No or True/False question
• Input/Output (Parallelogram): Data going in or out
• Arrow: Direction of flow
What is pseudocode?
A way of describing an algorithm using structured but plain English, resembling code but not specific to a language.
Why do we use pseudocode and flowcharts?
To plan programs clearly, understand logic, and communicate algorithms before actual coding.
What is linear search?
An algorithm that checks each item in a list one at a time until it finds the target or reaches the end of the list.
What is binary search?
An efficient algorithm that repeatedly divides a sorted list in half to find a target item.
What are the advantages of binary search over linear search?
Faster for large, sorted lists — reduces the number of checks needed.
What are the requirements for using binary search?
The list must be sorted in order.
What is a sorting algorithm?
An algorithm that arranges data into a specific order (e.g., ascending or descending).
What is bubble sort?
A sorting algorithm that repeatedly steps through a list, compares adjacent items, and swaps them if needed until the list is sorted.
What are the advantages and disadvantages of bubble sort?
• Advantages: Simple to understand and implement
• Disadvantages: Very inefficient for large lists
What is merge sort?
A sorting algorithm that divides the list into smaller parts, sorts them, and then merges them back together in order.
Compare bubble sort and merge sort.
• Bubble sort: Slower, simpler
• Merge sort: Faster and more efficient for large data sets, but uses more memory due to recursion and merging steps
How do you trace an algorithm?
By simulating it step by step, keeping track of variable values to understand what it does or find errors.
What is abstraction in algorithms?
Removing unnecessary details to focus on the main idea or logic of the problem.