Friday, April 13, 2012

course pages,quizes,tests,exams

CSC 257/457 - Computer Networks (Fall 2008)
http://www.cs.rochester.edu/~bukys/csc257-fall2008/


Computer Networks
http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-829-computer-networks-fall-2002/lecture-notes/


CS 268: Computer Networks, Spring 2003: Syllabus
http://inst.eecs.berkeley.edu/~cs268/sp03/



BBS 676 Veri Iletisimi ve Bilgisayar Aglari
http://www.ee.hacettepe.edu.tr/~toker/BBS676/BBS676-Homepage.html


BIL 472 Bilgisayar Aglari 2006-2007 Bahar Dönemi
http://www.gyte.edu.tr/dosya/104/ders/BIL472/


AYŞE BETÜL OKTAY BTP 213 Ağ Sistemleri 
http://www.fatih.edu.tr/~betulg/network.htm

Trees

  • Data Structures - Chapter 3: Tree-part1

http://www.youtube.com/watch?v=7Ac2qNITEYQ&feature=channel&list=UL




  • Tree (data structure)

In computer science, a tree is a widely used data structure that simulates a hierarchical tree structure with a set of linked nodes.
A tree can be defined recursively (locally) as a collection of nodes (starting at a root node), where each node is a data structure consisting of a value, together with a list of nodes (the "children"), with the constraints that no node is duplicated.
A tree can be defined abstractly as a whole (globally) as an ordered tree, with a value assigned to each node

Representations

There are many different ways to represent trees; common representations represent the nodes as dynamically allocated records with pointers to their children, their parents, or both, or as items in an array, with relationships between them determined by their positions in the array (e.g., binary heap).

http://en.wikipedia.org/wiki/Tree_(data_structure)





  • Trees

we shall extend the use of pointers to define a non-linear structure to model hierarchical relationships, such as a family tree.
In such a tree, we have links moving from an ancestor to a parent, and links moving from the parent to children

A tree is a data structure that is made of nodes and pointers, much like a linked list.
The difference between them lies in how they are organized

The height of a tree is defined to be the length of the longest path from the root to a leaf in that tree ( including the path to root)


Tree Examples
Directory Hierarchies:
In computers, files are stored in directories that form a tree.
The top level directory represents the root.
It has many subdirectories and files

Organization charts:

Biological classifications:
Starting from living being at the root, such a tree can branch off to mammals, birds, marine life etc

Game Trees:
All games which require only mental effort would always have number of possible options at any position of the game.
For each position, there would be number of counter moves.
The repetitive pattern results in what is known a game tree

http://www.cs.ucf.edu/courses/cop3502h.02/trees1.pdf





  • Trees have many uses:


representing family genealogies
as the underlying structure in decision-making algorithms
to represent priority queues (a special kind of tree called a heap)
to provide fast access to information in a database (a special kind of tree called a b-tree)
http://pages.cs.wisc.edu/~vernon/cs367/notes/8.TREES.html

linked list



  • Linked Lists in 10 minutes - I

http://www.youtube.com/watch?v=LOHBGyK3Hbs&feature=related

Disadvantages of arrays are
-when element is added all elements need to be shifted
-fixed size

with linked list these problems are overcame




  • linked list in plain english

http://www.youtube.com/watch?v=oiW79L8VYXk




  • advantages

The biggest advantage of linked lists is that they can be expanded in constant time without memory overhead. 

For example when you make an array you must allocate memory for a certain number of elements. 
If you want to add more elements to the array than you allocated for you must create a new array and copy the old array into the new array. 
This can take lots of time. 
You can prevent this by allocating lots of space initially but then you might allocate more than you need wasting memory. 

With a linked list you can start with space for just one element allocated. And add on new elements easily without the need to do any copying and reallocating. 

Read more: http://wiki.answers.com/Q/What_are_the_advantages_of_linked_lists#ixzz1xDOa8ksU





  • Linked lists have several advantages over dynamic arrays. 

Insertion or deletion of an element at a specific point of a list, assuming that we have a pointer to the node (before the one to be removed, or before the insertion point) already, is a constant-time operation, whereas insertion in a dynamic array at random locations will require moving half of the elements on average, and all the elements in the worst case.
While one can "delete" an element from an array in constant time by somehow marking its slot as "vacant", this causes fragmentation that impedes the performance of iteration.

Moreover, arbitrarily many elements may be inserted into a linked list, limited only by the total memory available; while a dynamic array will eventually fill up its underlying array data structure and will have to reallocate — an expensive operation,


http://en.wikipedia.org/wiki/Linked_list#Linked_list_operations





  • Linked lists are preferable over arrays when:


a) you need constant-time insertions/deletions from the list (such as in real-time computing where time predictability is absolutely critical)

b) you don't know how many items will be in the list. With arrays, you may need to re-declare and copy memory if the array grows too big

c) you don't need random access to any elements

d) you want to be able to insert items in the middle of the list (such as a priority queue)


  • Arrays are preferable when:


a) you need indexed/random access to elements

b) you know the number of elements in the array ahead of time so that you can allocate the correct amount of memory for the array

c) you need speed when iterating through all the elements in sequence. You can use pointer math on the array to access each element, whereas you need to lookup the node based on the pointer for each element in linked list, which may result in page faults which may result in performance hits.

d) memory is a concern. Filled arrays take up less memory than linked lists. Each element in the array is just the data. Each linked list node requires the data as well as one (or more) pointers to the other elements in the linked list.

Array Lists (like those in .Net) give you the benefits of arrays, but dynamically allocate resources for you so that you don't need to worry too much about list size and you can delete items at any index without any effort or re-shuffling elements around. Performance-wise, arraylists are slower than raw arrays.

http://stackoverflow.com/questions/393556/when-to-use-a-linked-list-over-an-array-array-list





  • When should I use LinkedList?


When you need efficient removal in between elements or at the start.
When you don't need random access to elements, but can live with iterating over them one by one



  • When should I use ArrayList?

When you need random access to elements ("get the nth. element")
When you don't need to remove elements from between others. It's possible but it's slower since the internal backing-up array needs to be reallocated.
Adding elements is amortized constant time (meaning every once in a while, you pay some performance, but overall adding is instantly done)






  • Making the decision

If your data is best represented using a multidimensional structure, or the number of elements is known in advance and will remain consistent, an array is best.
If your data is easily represented in one dimension, and the number of elements is unknown or is expected to change often throughout the operation of your program, a linked list is more efficient.

If your data will be searched and accessed often but will change infrequently, the array offers the least overhead for your expected operations.
If you expect to be regularly adding or subtracting elements, especially if you need to maintain a sorted order, the versatility of the linked list will be of greater benefi

http://www.techrepublic.com/article/deciding-whether-to-use-arrays-or-linked-lists/1050183



ArrayList is very useful when a well defined set of data is needed in a List interface as opposed to an array. It can be dynamically changed, but try not to do so frequently throughout the life of the application. LinkedList is there for you to do just that: Manipulating it is very easy, and as long as its used for iteration purposes only and not for random accessing, it’s the best solution. Further, if you need random accessing from time to time, I suggest toArray for that specific moment.

http://chaoticjava.com/posts/linkedlist-vs-arraylist/



  • Bagli listeler
Programlama açisindan liste, aralarinda dogrusal iliski olan veriler toplulugu olarak görülebilir. 
Yigit ve kuyruklarin genisletilmesi yani üzerlerindeki sinirlamalarin kaldirilmasi ile liste yapisina ulasilir.


Yigitlarda ve kuyruklarin gerçeklestiriminde sirali bellek kullaniminin (dizi) en büyük dezavantaji, hiç kullanilmasa veya az kullanilsa bile sabit miktardaki
bellegin bu yapilara ayrilmis olarak tutulmasidir.

Ayrica sabit bellek miktari asildiginda da tasma olusmasi ve eleman ekleme isleminin yapilamamasidir. 
Bagli listeler üzerinde gerçeklestirildiklerinde ise bu problemler ortadan kalkmaktadir.

Bir bagli listenin n. elemanina erismek için n tane islem yapmak yani kendinden önceki (n-1) eleman üzerinden geçmek gerekmektedir. 
Elemanlarin bellekteki yerleri dizilerdeki gibi sirali olmadigindan elemanlar ve siralari ile yerlestikleri bellek bölgeleri arasinda bir iliski yoktur.

Circular Linked Lists
Son elemanin bagi NULL degildir; ilk elemani gösterir.

Doubly Linked Lists
Her dügümü iki bag içerdigi bagli listelerdir.
ilk bag kendinden önceki dügümü gösterirken ikincisi de kendinden sonraki dügümü gösterir
Çift bagli listelerde, tek bagli listelerdeki geriye dogru listeleme ve dolasmadaki zorluklar ortadan kalkar.

Circular Doubly Linked Lists
ilk dügümden önceki dügüm son, son dügümden sonraki dügüm de ilk dügümdür.

Stack

Data Structures - Chapter 1: Stack

http://www.youtube.com/watch?v=_EyhFWwnvcs

Stack is a first in last out data structure
you can't do selective removal from a stack
selective removal is possible with data structure like array and linked list
push()
pop()
size()
isempty()
top()
to implement stack we use an array
linked list also can be used to implement stack

  • Polish notation (prefix notation)
It refers to the notation in which the operator is placed before its two operands . Here no parentheses are required, i.e.,

+AB 

Reverse Polish notation(postfix notation) –
It refers to the analogous notation in which the operator is placed after its two operands. Again, no parentheses is required in Reverse Polish notation, i.e.,

AB+ 


Stack organized computers are better suited for post-fix notation then the traditional infix ntation.
Thus the infix notation must be converted to the post-fix notation. The conversion from infix notation to post-fix notation must take into consideration the operational hierarchy. 

Highest: Exponentiation (^)
Next highest: Multiplication (*) and division (/)
Lowest: Addition (+) and Subtraction (-) 

Now we need to calculate the value of these arithmetic operations by using stack.

The procedure for getting the result is:

    Convert the expression in Reverse Polish notation( post-fix notation).
    Push the operands into the stack in the order they are appear.
    When any operator encounter then pop two topmost operands for executing the operation.
    After execution push the result obtained into the stack.
    After the complete execution of expression the final result remains on the top of the stack.

For example –

Infix notation: (2+4) * (4+6)
Post-fix notation: 2 4 + 4 6 + *
Result: 60 


From Postfix to Answer
•The reason to convert infix to postfix expression is that we can compute the answer of postfix expression easier by using a stack.

Postfix Expression

•Infix expression is the form AOB
–A and B are numbers or also infix expression
–O is operator ( +, -, *, / )

•Postfix expression is the form ABO
–A and B are numbers or also postfix expression
–O is operator ( +, -, *, / )

From Postfix to Answer

•Algorithm: maintain a stack and scan the postfix expression from left to right–If the element is a number, push it into the stack
–If the element is a operator O, pop twice and get A and B respectively. Calculate BOAand push it back to the stack
–When the expression is ended, the number in the stack is the final answer

Transform Infix to Postfix

•Observation 1: The order of computation depends on the order of operators 

–The parentheses must be added according to the priority of operations. 
–The priority of operator * and / is higher then those of operation + and –
–If there are more than one equal-priority operators, we assume that the left one’s priority is higher than the right one’s
•This is called left-to-right parsing.

https://faculty.utrgv.edu/john.abraham/6314/assignments/postfix%20tutorial.pdf

Infix to Postfix Conversion
•We use a stack
•When an operand is read, output it
•When an operator is read
–Pop until the top of the stack has an element of lower precedence
–Then push it
•When ) is found, pop until we find the matching (
•( has the lowest precedence when in the stack
•but has the highest precedence when in the input
•When we reach the end of input, pop until the stack is empty

https://cs.nyu.edu/courses/fall10/V22.0102-004/lectures/InfixToPostfixExamples.pdf

  • Infix to postfix conversion algorithm
A summary of the rules follows:

1. Print operands as they arrive.

2. If the stack is empty or contains a left parenthesis on top, push the incoming operator onto the stack.

3. If the incoming symbol is a left parenthesis, push it on the stack.

4. If the incoming symbol is a right parenthesis, pop the stack and print the operators until you see a left parenthesis. Discard the pair of parentheses.

5. If the incoming symbol has higher precedence than the top of the stack, push it on the stack.

6. If the incoming symbol has equal precedence with the top of the stack, use association. If the association is left to right, pop and print the top of the stack and then push the incoming operator. If the association is right to left, push the incoming operator.

7. If the incoming symbol has lower precedence than the symbol on the top of the stack, pop the stack and print the top operator. Then test the incoming operator against the new top of stack.

8. At the end of the expression, pop and print all operators on the stack. (No parentheses should remain.)

http://csis.pace.edu/~wolf/CS122/infix-postfix.htm


Queue


Data Structures - Chapter 2: Queue
http://www.youtube.com/watch?v=XBuScARSmAQ&feature=channel&list=UL

queue is a first in first out data structure
enqueue() to add
dequeue() to delete
size() return the # of elements
isempty()
front()


selective removal is not possible with queue data structure
queue can be implemented by array or linked list

course pages,quizes,tests,exams

bil222-veri-yapıları-ve-algoritmalar-2008-lec5.mpg
http://www.youtube.com/watch?v=xGwTZAfM6XE&feature=results_main&playnext=1&list=PLCF7B4C6E92388118

SEN 890 Data Structures
http://www.bhecker.com/itu/viewforum.php?f=1051


204 Data Structures (3+1)
http://yzgrafik.ege.edu.tr/~ugur/11_12_Fall/DS/index11.html


Lecture 1: Introduction to Data Structures and Algorithms - Richard Buckland
http://www.youtube.com/watch?v=RpRRUQFbePU


CSE 373: Data Structures & Algorithms, Autumn 2011
http://www.cs.washington.edu/education/courses/cse373/11au/

CS 124: Data Structures and Algorithms
http://www.fas.harvard.edu/~libcs124/cs124/lecture_notes.html


Data Structures Fall 2006
Professor Evan Korth
http://www.cs.nyu.edu/courses/fall06/V22.0102-001/index.html

Data Structures and Algorithms
http://www.cise.ufl.edu/~sahni/cop3530/


CIS300: Data structures and algorithms
http://people.cis.ksu.edu/~schmidt/300s05/Lectures/home.html

EENG212 Algorithms & Data Structures
http://faraday.ee.emu.edu.tr/eeng212/

CENG 707 - Data Structures and Algorithms (Fall 2011-2012)
http://www.ceng.metu.edu.tr/~tcan/ceng707_f1112/Schedule/index.shtml



Algorithms: Design and Analysis, Part I
https://www.coursera.org/

Algorithms (cs215)
http://www.udacity.com/

Introduction to Algorithms
http://courses.csail.mit.edu/6.006/spring11/notes.shtml

Data Structure & Algorithms Interview Questions

Data Structure & Algorithms Interview Questions And Answers
http://sites.google.com/site/interviewquestionsandanswers/data-structure-algorithms-interview-questions-and-answers

50 Algorithms Interview Questions
http://www.learn.geekinterview.com/resources/interview-articles/50-algorithms-interview-questions.html

Data Structures Questions and Answers for Technical Interviews
http://technical-interview.com/datastructures.aspx

Recursion


  • Recursion

Java #20 - Recursion Part 1
http://www.youtube.com/watch?v=Bu0X20xOxIs&feature=channel&list=UL


  • Java #21 - Recursion Part 2

http://www.youtube.com/watch?v=Mo59NNK8POE&feature=autoplay&list=ULBu0X20xOxIs&lf=channel&playnext=1


  • Fibonacci Series
http://www.java-examples.com/fibonacci-series-java-example

  • Example-Fibonacci Numbers
http://www.brpreiss.com/books/opus5/html/page75.html

  • Fibonacci numbers (Java)
http://en.literateprograms.org/Fibonacci_numbers_%28Java%29




  • What are advantages and disadvantages of recursive calling ?

Through Recursion one can Solve problems in easy way while
its iterative solution is very big and complex.
Ex : tower of Hanoi
You reduce size of the code when you use recursive call.

Disadvantages :
Recursive solution is always logical and it is very
difficult to trace.(debug and understand)


Recursive procedures are huge memory hogs. Also, they're a nightmare to debug. Finally, it's pretty rare to find an application that actually needs recursion as opposed to a simpler, more friendly methodolgy.

Read more: http://wiki.answers.com/Q/What_are_the_disadvantages_of_recursion#ixzz1xDJz1EG4






  • Use of recursion in an algorithm has both advantages and disadvantages. The main advantage is usually simplicity. The main disadvantage is often that the algorithm may require large amounts of memory if the depth of the recursion is very large.

http://en.wikipedia.org/wiki/Recursion



  • Advantages


Although at most of the times a problem can be solved without recursion, but in some situations in programming, it is a must to use recursion. For example, a program to display a list of all files of the system cannot be solved without recursion.
The recursion is very flexible in data structure like stacks, queues, linked list and quick sort.
Using recursion, the length of the program can be reduced.

Disadvantages

It requires extra storage space. The recursive calls and automatic variables are stored on the stack. For every recursive calls separate memory is allocated to automatic variables with the same name.
If the programmer forgets to specify the exit condition in the recursive function, the program will execute out of memory. In such a situation user has to press Ctrl+ break to pause and stop the function.
The recursion function is not efficient in execution speed and time.
If possible, try to solve a problem with iteration instead of recursion

http://my.safaribooksonline.com/book/programming/c/9788131760314/functions/section_10.20





  • Rule of the thumb: use recursion when it will shorten your development effort (usually in tree structures) and when performance is not an issue.


Recursive functions are perfect for tree structures. Loops are perfect for iterations and sequences.

public List GetAllFilesInTree(string path)
{
    List files = new List(GetAllFilesInFolder(path));
    foreach (string subdir in GetAllFoldersInFolder(path))
    {
        files.AddRange(GetAllFilesInTree(path));
    }
}



Advantages of Recursion
The code may be much easier to write.
Some situations are naturally recursive.


Naturally recursive data structures:
Linked lists.
Binary trees.

Naturally recursive problems:
Traversing linked lists.
Traversing binary trees.
Evaluating expressions.
Differentiating functions.
The Triangle puzzle.


Disadvantages of Recursion
Recursive functions are generally slower than
nonrecursive functions.
Excessive recursion may over?ow the run-time stack.
One must be very careful when writing recursive
functions; they can be tricky.
There is shallow recursion and there is deep recursion.
Shallow recursion will not over?ow the stack, but it may
take an excessively long time to execute.
Deep recursion is generally much faster, but it may
over?ow the stack.

The time and space overhead used by the stack on each call is a disadvantage of recursion. You should always minimize the number and size of the recursive function's arguments.





  • Recursion

Recursion means "defining a problem in terms of itself".
This can be a very powerful tool in writing algorithms.
Recursion comes directly from Mathematics, where there are many examples of expressions written in terms of themselves
http://www.cs.utah.edu/~germain/PPS/Topics/recursion.html



  • A brute force algorithm

A brute force algorithm attempts to check systematically all possible keys until the correct one has been found.
In the worst case the algorithm has to check each available combination in order to find the correct key.
https://janosch.woschitz.org/a-simple-brute-force-algorithm-in-c-sharp/

Finding a Brute Force Solution

  • Recursive Backtracking

A brute force algorithm is a simple but general approach
Try all combinations until you find one that works
This approach isn’t clever, but computers are fast
Then try and improve on the brute force resuts
http://www.cs.utexas.edu/~scottm/cs314/handouts/slides/Topic13RecursiveBacktracking_4Up.pdf




course pages,quizes,tests,exams

course pages,quizes,tests,exams


Bil354 Veri Tabani Sistemleri
http://web.cs.hacettepe.edu.tr/~ssen/teaching/bil354.html

BIL106 Veritabani Sistemleri
http://edogdu.etu.edu.tr/course/bil106/


Database Management Systems
http://myweb.brooklyn.liu.edu/gnarra/database/

Database Management Systems CIS 3400
http://cisnet.baruch.cuny.edu/holowczak/classes/3400/notes.html


CSC1270: Database Management Systems
http://www.cs.brown.edu/courses/cs127/