Midterm Questions Flashcards
Describe the binary search with proper steps?
Search a sorted array by repeatedly dividing the search interval in half. Begin with an interval covering the whole array. If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. Otherwise, narrow it to the upper half. Repeatedly check until the value is found or the interval is empty.
Describe the binary search with proper steps (Pseduo code)?
- Compare x with the middle element.
- If x matches with the middle element, we return the mid index.
- Else If x is greater than the mid element, then x can only lie in the right half subarray after the mid element. So we recur for the right half.
- Else (x is smaller) recur for the left half.
Define Machine Language:
A computer programming language consisting of binary or hexadecimal instructions which a computer can respond to directly.
Define programming language:
A programming language is a computer language engineered to create a standard form of commands. These commands can be interpreted into a code understood by a machine.
What are the difference between machine language and programming language?
Machine learning is the low-level programming langugage represented by 0s and 1s. It is only comprenhensible to computers and its diffcult for humans to understand.
Meanwhile, programming language allows humans to translate human intentions into executable algorithms. It is only comprehensible to humans and not to computers.
Define Algorithm:
A set of steps that defines how a task is performed
Define Program:
A representation of an algorithm
Define Programming:
The process of developing a program
Define Software:
Programs and the algorithms they represent
Define Hardware:
The machinery
How to breakdown a problem and convert them to algorithm:
Step 1: Obtain a description of the problem.
Step 2: Analyze the problem.
Step 3: Develop a high-level algorithm.
Step 4: Refine the algorithm by adding more detail.
Step 5: Review the algorithm.
Euclidean Algorithm
One of the oldest numerical algorithms still to be in common use. It solves the problem of computing the greatest common divisor (gcd) of two positive integers
Abstraction
The distinction between the external properties of an entity and the details of the entity’s internal composition
Data (how to store them)?
Numbers, text, images, sounds, and video
Difference between algorithm and programming language
an algorithm is a step-by-step procedure for solving the problem while programming is a set of instructions for a computer to follow to perform a task.