CP104 Lecture 1: lecture 1 - how to wirte prgoram and alogrithms
hayjayshay and 38575 others unlocked
2
CP104 Full Course Notes
Verified Note
2 documents
Document Summary
A program is a set of instructions that a computer follows to perform a task: data structures (collection of data items, algorithms (recipe for solving a problem) Ex) search (example # list) 2 ways to go about it: linear search. Start at the (cid:271)egi(cid:374)(cid:374)i(cid:374)g of the list look at ea(cid:272)h ele(cid:373)e(cid:374)t (cid:272)he(cid:272)ki(cid:374)g if it (cid:373)at(cid:272)hes what you"re looking for. Stopping when element is found: binary search. Assuming the elements are in order the list is split into 2. Checking the middle element to see if it"s lesser or greater tha(cid:374) what you"re looki(cid:374)g for. Greater than go left lesser than go right arriving at the middle again repeating this process until desired element is found. Steps in writing a program: design the program. Write the algorithm: write the code, correct syntax errors, test program, correct logical errors. Given a 2d maze find a path through it. A function that reads the maze from a file.