   # Konu: Linklisted, Queue, Stack, Trees???

1. ## Linklisted, Queue, Stack, Trees???

Data Structure için baslıktaki konuları içeren örnek uygulama anlatımıyla(anlatımı biraz basit olsa çok iyi olur ) önerebileceğiniz internet üzerinden kaynak arıyorum birazcık acil.. Teşekkür ederim şimdiden..  Alıntı

2. ## SimilarŞu alt başlıkları gördünüz mü?

Bir kaçını burada açalım:

Data Structure -- Permutations

What is a permutation?

QUOTE
Permutation is the rearrangement of objects or symbols into distinguishable sequences. Each unique ordering is called a permutation. For example, with the numerals one to six, each possible ordering consists of a complete list of the numerals, without repetitions. There are 720 total permutations of these numerals, one of which is: "4, 5, 6, 1, 2, 3".

The general concept of permutation can be defined more formally in different contexts:

* In set theory, a permutation is an ordered sequence containing each symbol from a set once, and only once. A permutation is distinct from a set or combination, in that the ordering of elements in a set is not considered relevant for sets or combinations. In other words, the set-theoretic definition of permutation is that of a one-to-one correspondence, or bijection, of labeled elements with "positions" or "places" which are arranged in a straight line.
* In abstract algebra and related areas, the elements of permutation may not be arranged in a linear order, or indeed in any order at all. Under this refined definition, a permutation is a bijection from a finite set, X, onto itself. This allows for the definition of groups of permutations; see permutation group.
* In combinatorics, the term permutation also has a traditional meaning which includes ordered lists without repetition and where one or more elements from the list are omitted from the distinguishable orderings; for example, a permutation of "1,2,4,3" with "5" and "6" omitted.

Here i have one possible solution from my friend.... (Pallavi)
1.Concat the input string with itself : manman
2. initialise the ptr to first element
3. Print it length of the string
4. Move the ptr by one position ( keep incrementing till length times) and perform step 3
5. reverse the whole string and repeat steps 2, 3, 4

Any better solutions? WELCOME !!!
----
---
CODE
\$tmp = array();
\$s = 'the string you wish to permute, in the example, e.g. man';
\$out = '';
\$ctr=0;

function perm(\$ctr) {
global \$out;
global \$s;
global \$tmp;
//echo \$out;
if (\$ctr == strlen(\$s)) {
echo \$out . "\n";
}
else {
for (\$i=0;\$i<strlen(\$s);\$i++) {
//echo 'a';
if (!\$tmp[\$i]) {
\$tmp[\$i]=TRUE;
\$out .= \$s[\$i];
perm(\$ctr+1);
\$tmp[\$i]=FALSE;
\$out = substr(\$out, 0, -1);
}
}
}
}

perm(0);

----
----
Implement a Queue using a stack.
No restriction on space complexity.

One possible Solutions
a costly procedure...
1. Use a temp stack
2. Insertion into queue
- Push the element into the original stack
3. Deletion from queue
- Pop all the elements from stack into a temp stack
- pop out the first element from the temp stack
- pop all the remaining elements back to the original stack

QUOTE
A queue is a particular kind of collection in which the entities in the collection are kept in order and the principal (or only) operations on the collection are the addition of entities to the rear terminal position and removal of entities from the front terminal position. This makes the queue a First-In-First-Out (FIFO) data structure. In a FIFO data structure, the first element added to the queue will be the first one to be removed. This is equivalent to the requirement that whenever an element is added, all elements that were added before have to be removed before the new element can be invoked. A queue is an example of a linear data structure.

Queue (data structure)

From Wikipedia, the free encyclopedia

Jump to: navigation, search
Linear data structuresArray
Deque
Heap
Linked list
Queue
Stack

A queue (pronounced /kjuː/) is a particular kind of collection in which the entities in the collection are kept in order and the principal (or only) operations on the collection are the addition of entities to the rear terminal position and removal of entities from the front terminal position. This makes the queue a First-In-First-Out (FIFO) data structure. In a FIFO data structure, the first element added to the queue will be the first one to be removed. This is equivalent to the requirement that whenever an element is added, all elements that were added before have to be removed before the new element can be invoked. A queue is an example of a linear data structure.
Queues provide services in computer science, transport and operations research where various entities such as data, objects, persons, or events are stored and held to be processed later. In these contexts, the queue performs the function of a buffer.
Queues are common in computer programs, where they are implemented as data structures coupled with access routines, as an abstract data structure or in object-oriented languages as classes. Common implementations are circular buffers and linked lists.
Contents

Common operations from the C++ Standard Template Library include the following:
bool empty() Returns True if the queue is empty, and False otherwise. T& front() Returns a reference to the value at the front of a non-empty queue. There is also a constant version of this function, const T& front(). void pop() Removes the item at the front of a non-empty queue. void push(const T& foo) Inserts the argument foo at the back of the queue. int size() Returns the total number of elements in the queue l

Example C++ Program

Based on an example in Ford and Topp Data Structures with C++ page 387.

queue< char > theQueue; // creates a queue of chars named "theQueue"theQueue.push('a'); // theQueue now contains "a"theQueue.push('b'); // theQueue now contains "a b"theQueue.push('c'); // theQueue now contains "a b c"cout << "theQueue contains: a b c" << endl << endl;while( !theQueue.empty() ) // while the queue is not empty...{ cout << "Size = " << theQueue.size() << endl; // ...output queue size cout << "Value at front = " << theQueue.front() << endl << endl; // ...and output the first element value theQueue.pop(); // ...and remove it}

Representing a Queue

The defining attribute of a queue data structure is the fact that allows access to only the front and back of the structure. Furthermore, elements can only be removed from the front and can only be added to the back. In this way, an appropriate metaphor often used to represent queues is the idea of a checkout line (Ford/Topp p. 385). Other examples of queues are people traveling up an escalator, machine parts on an assembly line, or cars in line at a gas station. The recurring theme is clear: queues are essentially the same as a queue you would get in a shop waiting to pay.
In each of the cases, the customer or object at the front of the line was the first one to enter, while at the end of the line is the last to have entered. Every time a customer finishes paying for their items (or a person steps off the escalator, or the machine part is removed from the assembly line, etc.) that object leaves the queue from the front. This represents the queue “dequeue” function. Every time another object or customer enters the line to wait, they join the end of the line and represent the “enqueue” function. The queue “size” function would return the length of the line, and the “empty” function would return true only if there was nothing in the line.
kaynak:
http://www.trap17.com/index.php/Data...ck_t53321.html

http://en.wikipedia.org/wiki/Queue_%28data_structure%29

Data Structures -- Expression Trees

Construct an expression tree for the expression (a || && (c || d)

After constructing the tree convert the tree to correspond to the associative property of the given expression.

Eg: (1 + 2) * ( 3 + 4) = (1 * 3) + (1 * 4) + (2 * 3) + (2 * 4)

Similar to that, from the constructed expression tree, construct a new expression tree such that inorder traversal of the new tree will be associative value of the given expression

Inorder traversal of the new tree should be (a && c) || (a && d) || (b && c) || (b && d)

Write a generic algorithm to convert the first tree to the second tree..

What is an Expression Tree??
Visit links below.
http://www.brpreiss.com/books/opus5/html/page264.html
http://www.cs.jhu.edu/~goodrich/dsa/05trees/Demo1/

Tree Traversals
Visit the below links for knowing more about tree traversals.
http://en.wikipedia.org/wiki/Tree_traversal
http://www.brpreiss.com/books/opus4/html/page260.html

-----
-----

Daha Fazlası için

Topics

Keywords : data, structures, string, arrange, based, repetition, string, data, structure

1. Data Structure -- Permutations
<A style="TEXT-DECORATION: none" href="http://www.trap17.com/index.php/Data-Structure-Permutations_t53966.html">(1)
2. Data Structure -- Queue -- Implement Using Stack
Implement a Queue using a stack. No restriction on space complexity. One possible Solutions a  Alıntı

#### Konu Bilgileri

##### Users Browsing this Thread

Şu an 1 kullanıcı var. (0 üye ve 1 konuk)

#### Bu Konudaki Etiketler #### Yetkileriniz

• Konu Acma Yetkiniz Yok
• Cevap Yazma Yetkiniz Yok
• Eklenti Yükleme Yetkiniz Yok
• Mesajınızı Değiştirme Yetkiniz Yok
Yemek Tarifleri   RisaleForum grubuna abone ol E-posta: Bu grubu ziyaret et

Search Engine Friendly URLs by vBSEO 3.6.0