here

In The Name of God, The Merciful, The compassionate
Undergraduate Course – Computer Engineering
Data Structure and Algorithm (DS)
Department of Computer Engineering
Sharif University of Technology
Spring 2015
Instructor: Hamidreza Mahyar
Class Hours & Location: Saturday & Monday; 18:00 – 19:30 (CE Department)
Office: CE Department #815
Phone: 6616-6678
Email: [email protected]
URL: http://ce.sharif.edu/~hmahyar
TAs:
Arman Haghighi (Head)
Email: [email protected]
Moein Zamani
Email: [email protected]
Sina Hasanzade
Email: [email protected]
Reza Ranjkesh
Email: [email protected]
Amir Khosrojerdi
Email: [email protected]
Course Website: http://ce.sharif.edu/~hmahyar/DataStructure-Spring2015/DS.html
Course Objectives: Before there were computers, there were algorithms. But now that there are
computers, there are even more algorithms and algorithms lie at the heart of computing. This course
provides a comprehensive introduction to the modern study of computer algorithms. It presents many
algorithms and covers them in considerable depth, yet makes their design and analysis accessible to all
levels of students. We have tried to keep explanations elementary without sacrificing depth of coverage or
mathematical rigor. Each part of this course presents an algorithm, a design technique, an application
area, or a related topic. Algorithms are described in English and in a pseudocode designed to be readable
by anyone who has done a little programming.
‫‪Course Textbook:‬‬
‫‪1. T.Corman, C.Leiserson, R.Rivest & C.Stein (CLRS): Introduction to Algorithms, MIT press,‬‬
‫‪September 2001.‬‬
‫‪2. M.Ghodsi, Data Structures and Algorithms Fundementals, Fatemi press,1388.‬‬
‫‪Grading: Based on Homework, Critical Reading, Project, Quizzes and Final Exam. The grade will be‬‬
‫‪determined by:‬‬
‫)‪Homework: 25 (Points‬‬
‫)‪Project: 15 (Points‬‬
‫)‪Quiz: 25 (Points‬‬
‫)‪Final Exam: 35 (Points‬‬
‫)‪Total: 100 (Points‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪Course Outline:‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫اﻟﮕﻮرﯾﺘﻢ‬
‫ﺑﺮﻧﺎﻣﻪ‬
‫ﺳﺎﺧﺘﻤﺎن داده‬
‫ﻣﻘﺪﻣﻪاي ﺑﺮ ﺗﺤﻠﯿﻞ ﭘﯿﭽﯿﺪﮔﯽ زﻣﺎﻧﯽ و ﻣﺮﺗﺒﻪ اﺟﺮاﯾﯽ اﻟﮕﻮرﯾﺘﻢﻫﺎ‬
‫ﻋﻼﻣﺖ ﮔﺬاري ﻣﺠﺎﻧﺒﯽ‬
‫ﺗﮑﺮار ﺣﻠﻘﻪﻫﺎ و ﻣﺮﺗﺒﻪ زﻣﺎﻧﯽ‬
‫ﺗﻮاﺑﻊ و زﯾﺮﺑﺮﻧﺎﻣﻪﻫﺎي ﺑﺎزﮔﺸﺘﯽ )‪(Recursion‬‬
‫ﺣﻞ ﻣﻌﺎدﻻت ﺑﺎزﮔﺸﺘﯽ‬
‫ﺷﻤﺎرش ﮔﺎمﻫﺎ ﯾﺎ ﻗﺪمﻫﺎ ﯾﺎ ﻣﺮاﺣﻞ ﯾﮏ ﺑﺮﻧﺎﻣﻪ‬
‫آراﯾﻪﻫﺎ )‪(Array‬‬
‫ﻣﺎﺗﺮﯾﺲﻫﺎ )‪(Matrix‬‬
‫ﺟﺴﻨﺠﻮ در آراﯾﻪ‬
‫ﭘﺸﺘﻪﻫﺎ )‪(Stack‬‬
‫اﻟﮕﻮرﯾﺘﻢﻫﺎي ‪) pop‬ﺣﺬف( و ‪) push‬درج( در ﭘﺸﺘﻪ‬
‫ارزﺷﯿﺎﺑﯽ ﻋﺒﺎرتﻫﺎي ﻣﺤﺎﺳﺒﺎﺗﯽ‬
‫درﺧﺖ ﻋﺒﺎرت ﻣﺤﺎﺳﺒﺎﺗﯽ )درﺧﺖ ﭘﺎرس(‬
‫ﻋﺒﺎرات ﻣﯿﺎﻧﻮﻧﺪي )‪ ،(infix‬ﭘﺴﻮﻧﺪي )‪ (postfix‬و ﭘﯿﺸﻮﻧﺪي )‪(prefix‬‬
‫ﺗﺒﺪﯾﻞ ﻋﺒﺎرت ‪ infix‬ﺑﻪ ﻋﺒﺎرتﻫﺎي ‪ postfix‬و ‪prefix‬‬
‫ﺗﺒﺪﯾﻞ ﻋﯿﺎرت ‪ postfix‬و ‪ prefix‬ﺑﻪ ﻋﺒﺎرت ‪infix‬‬
‫ﺗﺒﺪﯾﻞ ﻋﺒﺎرت ‪ prefix‬ﺑﻪ ﻋﺒﺎرت ‪ postfix‬و ﺑﺎﻟﻌﮑﺲ‬
‫ﺻﻒ )‪(Queue‬‬
‫ﺻﻒ ﺧﻄﯽ‬
‫ﺷﺮاﯾﻂ ﻣﺮزي و اوﻟﯿﻪ‬
‫ﻣﺸﮑﻞ ﺻﻒﻫﺎي ﺧﻄﯽ‬
‫ﺻﻒ ﺣﻠﻘﻮي )‪(Circular Queue‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫ﺟﻨﮕﻞ )‪(Forest‬‬
‫درﺧﺖ ﻧﺨﯽ دودوﯾﯽ )‪(Binary Thread Tree‬‬
‫درﺧﺖ ﺟﺴﺘﺠﻮي دودوﯾﯽ )‪(BST, Binary Search Tree‬‬
‫ﮐﺎرﺑﺮدﻫﺎي درﺧﺖ ﺟﺴﺘﺠﻮي دودوﯾﯽ‬
‫درج در درﺧﺖ ﺟﺴﺘﺠﻮي دودوﯾﯽ‬
‫ﺣﺬف از درﺧﺖ ﺟﺴﺘﺠﻮي دودوﯾﯽ‬
‫درﺧﺖ ﺑﺎ ارﺗﻔﺎع ﻣﺘﻮازن‬
‫درﺧﺖ ﺟﺴﺘﺠﻮي دودوﯾﯽ ﺑﺎ ارﺗﻔﺎع ﻣﺘﻮازن )‪(AVL‬‬
‫ﻣﺘﻮازن ﮐﺮدن درﺧﺖ ﺟﺴﺘﺠﻮي ﻧﺎﻣﺘﻮازن‬
‫درﺧﺖ ‪) Heap‬ﻧﯿﻤﻪ ﻣﺮﺗﺐ ‪ -‬ﻫﺮم(‬
‫ﺟﺴﺘﺠﻮي ﻣﺎﮐﺰﯾﻤﻢ و ﻣﯿﻨﯿﻤﻢ در ‪Heap‬‬
‫درج ﮔﺮه در ‪Heap‬‬
‫ﺣﺬف ﮔﺮه از ‪Heap‬‬
‫ﮐﺎرﺑﺮدﻫﺎي درﺧﺖ ‪Heap‬‬
‫ادﻏﺎم آراﯾﻪﻫﺎ ﺑﺎ درﺧﺖ اﻧﺘﺨﺎﺑﯽ‬
‫درﺧﺖ ﺗﻮﺳﻌﻪ ﯾﺎﻓﺘﻪ )دودوﯾﯽ ﻣﺤﺾ(‬
‫ﮔﺮاف )‪(Graph‬‬
‫ﻫﻤﺴﺎﯾﮕﯽ ﯾﺎ ﻣﺠﺎور ﺑﻮدن )‪(Adjacent‬‬
‫ﻧﻤﺎﯾﺶ ﮔﺮاف‬
‫ﻣﺎﺗﺮﯾﺲ ﻣﺠﺎورﺗﯽ )‪(Adjacent Matrix‬‬
‫ﻟﯿﺴﺖ ﻣﺠﺎورﺗﯽ )‪(Adjacent List‬‬
‫ﻟﯿﺴﺖ ﻣﺠﺎورﺗﯽ ﻣﻌﮑﻮس )‪(Reverse Adjacent List‬‬
‫درﺧﺖ ﭘﻮﺷﺎ )‪(Spanning Tree‬‬
‫ﭘﯿﻤﺎﯾﺶ ﮔﺮافﻫﺎ )‪(Graph Traversing‬‬
‫درﺧﺖ ﭘﻮﺷﺎي ﮐﻢﻫﺰﯾﻨﻪ )‪(Minimum Spanning Tree‬‬
(Sort) ‫ﻣﺮﺗﺐ ﺳﺎزي‬
(Bubble Sort) ‫ﻣﺮﺗﺐ ﺳﺎزي ﺣﺒﺎﺑﯽ‬
(Insertion Sort) ‫ﻣﺮﺗﺐ ﺳﺎزي درﺟﯽ‬
(Selection Sort) ‫ﻣﺮﺗﺐ ﺳﺎزي اﻧﺘﺨﺎﺑﯽ‬
(Merge Sort) ‫ﻣﺮﺗﺐ ﺳﺎزي ادﻏﺎﻣﯽ‬
(BST Sort) ‫ﻣﺮﺗﺐ ﺳﺎزي درﺧﺘﯽ‬
(Quick Sort) ‫ﻣﺮﺗﺐ ﺳﺎزي ﺳﺮﯾﻊ‬
(Heap Sort) ‫ﻣﺮﺗﺐ ﺳﺎزي ﻫﺮﻣﯽ‬
(Radix Sort) ‫ﻣﺮﺗﺐ ﺳﺎزي ﻣﺒﻨﺎ‬
(Shell Sort) ‫ﻣﺮﺗﺐ ﺳﺎزي ﺷﻞ‬
(Decision Tree) ‫درﺧﺖ ﺗﺼﻤﯿﻢ ﮔﯿﺮي‬
(HASHING) ‫درﻫﻢ ﺳﺎزي‬
(COLLISION) ‫ﺗﺼﺎدم‬













(Linked List) ‫ﻟﯿﺴﺖﻫﺎي ﭘﯿﻮﻧﺪي‬
‫ﻟﯿﺴﺖﻫﺎي ﭘﯿﻮﻧﺪي ﺧﻄﯽ‬
‫ﻟﯿﺴﺖﻫﺎي ﭘﯿﻮﻧﺪي ﺣﻠﻘﻮي‬
‫ﻟﯿﺴﺖﻫﺎي ﭘﯿﻮﻧﺪي دوﻃﺮﻓﻪ‬
‫ﭘﺸﺘﻪ ﭘﯿﻮﻧﺪي‬
‫ﺻﻒ ﭘﯿﻮﻧﺪي‬
‫ﻣﻌﮑﻮس ﮐﺮدن ﻟﯿﺴﺖ ﭘﯿﻮﻧﺪي‬
(Tree) ‫درﺧﺖ‬
‫ﻧﻤﺎﯾﺶ درﺧﺘﺎن ﻋﻤﻮﻣﯽ‬
(Binary) ‫درﺧﺖ دودوﯾﯽ‬
‫ﻧﻤﺎﯾﺶ درﺧﺘﺎن دودوﯾﯽ‬
‫ﭘﯿﻤﺎﯾﺶ درﺧﺘﺎن دودوﯾﯽ‬
‫ﺗﺒﺪﯾﻞ درﺧﺖ ﻋﺎدي )ﻋﻤﻮﻣﯽ( ﺑﻪ درﺧﺖ دودوﯾﯽ‬
Homework Problems:
Homework problems will be handed out on Sundays and will be due based on the deadline, before the
beginning of lectures. The problems will cover the following week materials so do not expect to cover the
whole problem set related materials right after the release. Course policy for late submission is mentioned
below:




-5% for each day delay up to the first 4 days after the deadline
After that you will lose -10% each day up to one week after the deadline
20% of the whole point for delivery up to two weeks after the deadline.
Do not even think of submission after more than two weeks delay!
Quizzes and Exams:
Each Saturday, there will be a quiz at the beginning of the lectures. Each quiz will cover the facts
discussed in the previous week, so use your Fridays to study! You will have 12 quizzes that 1 of them will
be dropped!
Statement on Collaboration, Academic Honesty, and Plagiarism:
We encourage working together whenever possible on; homework, working problems in tutorials, and
discussing and interpreting reading assignments. Talking about the course material is a great way to learn.
Regarding homework, the following is a fruitful (and acceptable) form of collaboration; discuss with your
classmates possible approaches to solving the problems, and then have each one fill in the details and
write her/his own solution independently. An unacceptable form of dealing with homework is to copy a
solution that someone else has written. We discourage, but do not forbid, use of materials from prior
terms that students may have access to. Furthermore, at the time that you are actually writing up your
solutions, these materials must be set aside; copy-editing from other’s work is not acceptable. At the top
of each homework you turn in, we expect you to briefly list all sources of information you used, except
known course materials like Text Book, Lectures, etc. A brief note such as “Did homework with ABC













and ABD in study group” or “Looked at old solution for Problem 4” would be sufficient. Besides the
morality issues, it will help TAs on grading your hand outs. There will be a zero tolerance policy for
Cheating/Copying HW’s. The first time you are caught, you will receive a zero for the task at hand. If you
are caught for a second time, you will fail the course. In general, we expect students to adhere to basic,
common sense concepts of academic honesty. Presenting another's work as if it was your own, or
cheating in exams will not be tolerated.