




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Information about assignment 1 and quiz 1 for the comp9007: algorithms course. It includes details about the due date, quiz schedule, and covered topics such as asymptotic order of growth and data structures like linked lists and queues. Students will learn about the importance of data structures, their operations, and their applications.
Typology: Lecture notes
1 / 101
This page cannot be seen from the preview
Don't miss anything!





























































































› Assignment 1:
› Due by 22 March 11:59PM.
› Quiz 1:
› Will be on conducted during tutorial time Friday the 22nd^ of March.
› Upper bounds. T(n) is O(f(n)) if there exist constants c > 0 and n (^0) ≥ 0 such that for all n ≥ n 0 we have T(n) ≤ c · f(n). › Lower bounds. T(n) is Ω(f(n)) if there exist constants c > 0 and n (^0) ≥ 0 such that for all n ≥ n 0 we have T(n) ≥ c · f(n). › Tight bounds. T(n) is Θ(f(n)) if T(n) is both O(f(n)) and Ω(f(n)). 3 Asymptotic Order of Growth 1 10 100 1, 10, 1 10 100 1,
3n 2n+ n
› Programs manipulate data
› Data should be organized so manipulations will be efficient
› Better programs are powered by good data structures
› Naïve choices are often much less efficient than clever choices
› Data structures are existing tools that can help you
› A linked list is
next
elem node
› "Head" points to the first element in the list.
› “Tail” points to the last element in the list.
Head Tail
first element
node
Head ∅
Tail
null
new node
node
Linked Lists (^12)
› A doubly linked list is often more convenient!
› Nodes store:
› Special trailer and header nodes
prev next
elem
header nodes/positions^ trailer
elements
node
› In a doubly linked list
› Direct applications
› Indirect applications
Algorithm ParenMatch(X,n):
I nput: An arrayX ofn tokens, each of which is either a grouping symbol, a variable, an arithmetic operator, or a number
Output: true if and only if all the grouping symbols inX match
LetS be an empty stack for i=0 ton-1 do if X[i] is an opening grouping symbol then S.push(X[i]) else if X[i] is a closing grouping symbol then if S.isEmpty() then return false {nothing to match with} if^ S.pop() does not match the type ofX[i]^ then return false {wrong type} if S.isEmpty() then return true {every symbol matched} else return false {some symbols were never matched}