2014 soft test programmer-frequent test knowledge point review notes [Chapter 2]

Source: Internet
Author: User

51cto college specially sorted out "2014 soft test programmer-General test knowledge point review notes [summary]" in the soft test preparation season to help schools pass through smoothly! For more software proficiency test counseling and questions, please pay attention to the 51cto college-soft exam classification!


View summary:2014 soft test programmer-frequent test knowledge point review notes [summary]650) This. width = 650; "alt =" popular article "src =" http://www.exam8.com/images/hot.gif "style =" padding: 0px; margin: 0px; Vertical-align: middle; Border: 0px; "/>


Three non-Recursive Algorithms for binary tree traversal)

  1. Traverse non-Recursive Algorithms in sequence

# Define Max size 100

Typedef struct

{

Bitree ELEM [maxsize];

Int top;

} Sqstack;

Void preorderunrec (bitree T)

{

Sqstack S;

Stackinit (s );

P = T;

While (P! = NULL |! Stackempty (s ))

{

While (P! = NULL) // traverse the left subtree

{

Visite (p-> data );

Push (S, P );

P = p-> lchild;

} // Endwhile

If (! Stackempty (s) // uses the embedded while in the next loop to implement the right subtree Traversal

{

P = POP (s );

P = p-> rchild;

} // Endif

} // Endwhile

} // Preorderunrec

2. Non-recursive algorithm for sequential Traversal

# Define Max size 100

Typedef struct

{

Bitree ELEM [maxsize];

Int top;

} Sqstack;

Void inorderunrec (bitree T)

{

Sqstack S;

Stackinit (s );

P = T;

While (P! = NULL |! Stackempty (s ))

{

While (P! = NULL) // traverse the left subtree

{

Push (S, P );

P = p-> lchild;

} // Endwhile

If (! Stackempty (s ))

{

P = POP (s );

Visite (p-> data); // access the root node

P = p-> rchild; // use the next loop to traverse the right subtree

} // Endif

} // Endwhile

} // Inorderunrec

3. Post-order traversal of non-Recursive Algorithms

# Define Max size 100

Typedef Enum {L, r} tagtype;

Typedef struct

{

Bitree PTR;

Tagtype tag;

} Stacknode;

Typedef struct

{

Stacknode ELEM [maxsize];

Int top;

} Sqstack;

// Post-order traversal

Void postorderunrec (bitree T)

{

Sqstack S;

Stacknode X;

Stackinit (s );

P = T;

Do

{

While (P! = NULL) // traverse the left subtree

{

X. PTR = P;

X. Tag = L; // mark as left subtree

Push (S, X );

P = p-> lchild;

}

While (! Stackempty (s) & S. ELEM [S. Top]. Tag = r)

{

X = POP (s );

P = x. PTR;

Visite (p-> data); // The tag is R, indicating that the access to the right subtree is complete, so the access to the root node

}

If (! Stackempty (s ))

{

S. ELEM [S. Top]. Tag = r; // traverse the right subtree

P = S. ELEM [S. Top]. PTR-> rchild;

}

} While (! Stackempty (s ));

} // Postorderunrec

4. Hierarchical Traversal Algorithm

// Binary tree data structure

Structbinarytree

{

Int value; // no template is written. The data type of the node is temporarily replaced by an integer.

Binarytree * left;

Binarytree * right;

};

Binarytree * root; // The root node of the known binary tree

// Hierarchical Traversal

Voidlevel (const binarytree * root)

{

Queue * Buf = new Queue (); // defines an empty queue. Assume that the node data type of this queue is also integer.

Binarytree t; // a Temporary Variable

Buf. push_back (Root); // queue the root node

While (BUF. Empty = false) // when the queue is not empty

{

P = Buf. Front (); // retrieves the first element of the queue.

Cout




Recommended high-quality articles:

Preparing for the 2014 soft exam! Recommendation of high-quality video tutorials (Comprehensive review + experience sharing + pre-test Sprint)

Knowledge points of Network Management in 2014 computer soft examination [summary]

Exercise questions and answers for the 2014 soft exam Network Administrator examination [summary]

2014 soft test programmer-test-exercise questions before the test [summary]


For online soft test video tutorials, click:

Http://edu.51cto.com/course/courseList/id-44.html



650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/3D/9F/wKioL1PE_n3z629yAACXIHScsJM092.jpg "alt =" wkiol1pe_n3z629yaacxihscsjm092.jpg "style =" padding: 0px; margin: 0px; Vertical-align: Top; Border: none; "/>


This article is from the "51cto college official blog" blog, please be sure to keep this source http://51edu.blog.51cto.com/8899635/1539367

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.