GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Programming  >  Algorithms
Go To First  |  Previous Question  |  Next Question 
 Algorithms  |  Question 36 of 37    Print  
Algorithm to Traverse Binary Tree
Design a conventional iterative algorithm to traverse a binary tree represented in linked lists in preorder.


  
Total Answers and Comments: 1 Last Update: August 14, 2009     Asked by: Dheerendra_juli 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
August 14, 2009 07:43:33   #1  
ratanlal Member Since: August 2009   Contribution: 1    

RE: Algorithm to Traverse Binary Tree
preorder(node root)
if root NULL;
return
else
do
print "root->data"
preorder(root->left)
preorder(root->right)
end else

 
Is this answer useful? Yes | No

 Related Questions

Write an algorithm to find the minimum of numbers where N is any arbitary natural number. N is given to you by the user as the first value.
Read Answers (2) | Asked by : marzieh eskandari

Example : 1)m = 3,n = 2 a11 a12 a21 a22a31 a32Output : a11 a21 a12 a31 a22 a322) m = 3, n = 4a11 a12 a13 a14a21 a22 a23 a24a31 a32 a33 a34Output : a11 a21 a12 a31 a22 a13 a32 a23 a14 a33 a24 a34 
Latest Answer : define two varibles initial_x and initial_y define another two varibles x and yint initial_x =  m;int initial_y = n;while (x != m && y! =n){ print (x,y) x--; y++; // Traverse downwards first if (initial_x

Implement an algorithm that takes two strings as input, and returns the intersection of the two, with each letter represented at most once. Speed it up and test it.  
Latest Answer : I think of an idea to do this by using a hash table. First, loop through first string, creat map, we can use ascii value of the char as the value. Only insert the char/int pair when a char can not be found in the hash table. After first ...

Give an algorithm that calculates the distance between two text strings (only operations you can have are: delete, add, and change, one by one). 
Latest Answer : The distance of two strings, like "car" and "cat", is 1. So all we need to do is, compare two strings one character by one character and get the distance value. The complexity is O(max(m,n)), m, n are the length of each string. ...

Bring out the importance of Algorithms in the field of Computer Science? 
Latest Answer : In simple terms algorithms are a blue print and logic design for building functionality with programming languages. Write the algorithm..Validate the algorithm, check the characteristics of the algorithm before implementing the algorithm.Optimize the ...

List out the characteristics of an algorithm 
Latest Answer : should have the following five characteristics:1. Input2. Output3. Definiteness4. Effectiveness5. Termination ...

What is validation of an algorithm? 
Latest Answer : The process of measuring the effectiveness of an algorithm before it is coded to know the algorithm is correct for every possible input.This process is called validation. ...

What is meant by algorithm profiling? 
Latest Answer : In recent years, several very efficient exact optimization algorithms have been developed in the computer science community. Examples are maximum flow algorithms, minimum-cost flow techniques, matching methods, which all are graph theoretical approaches ...

Write an algorithm that calculates all the elements of rows and columns of a square matrix and calculate the total of primary and secondary diagonal. 
View Question | Asked by : wiseboy

What is the complexity of a algorithm of finding the Cyclic Directed Graph? 
Latest Answer : use BFS or DFS time complexity is O(V+E) ...


 Sponsored Links

 
Related Articles

Tree Topology

Tree Topology Among all the Network Topologies we can derive that the Tree Topology is a combination of the bus and the Star Topology The tree like structure allows you to have many servers on the network and you can branch out the network in many ways This is particularly helpful for colleges unive
 

Concepts of Object-Oriented Programming

Object Oriented JavaScript In this chapter you ll learn about OOP Object Oriented Programming and how it relates to JavaScript As an ASP NET developer you probably have some experience working with objects and you may even be familiar with concepts such as inheritance However unless you re already a
 

What is B-Tree

B-Tree is an indexing technique most commonly used in databases and file systems where pointers to data are placed in a balance tree structure so that all references to any data can be accessed in an equal time frame. It is also a tree data structure which keeps data sorted so that searching, insert
 

SQL Programming

SQL Programming Overview Anybody who has done something for a long time has probably wanted to change how things work at some point or another. A worker at a mill might have found a more efficient way of cutting logs, or a mathematics teacher might have had a hand in changing a school’s al
 

The Interview Snafu

How to turn someone else’s mistake to your advantage Your dream job is about to become reality. A recruiter gave you the heads up about the perfect position at Humungous Conglomerate, Inc. You went through five interviews as well as a battery of psychological tests mandated by their HR de
 

Winning a Job Interview with a Winning Resume

Does your resume unlock your potential, take your skills to the highest level and win you the interview and the job you want now? The job market today is highly competitive and even if you think you have what it takes to get an interview you won’t get over the line without a polished, prof
 

WinRunner Programming Concepts

If you want to create WinRunner scripts that are highly efficient, there are important programming concepts that you will want to become familiar with. Understanding these concepts will provide you with a large number of key benefits. In addition to understanding these concepts, you must also learn
 

Programming Languages Certification

IT Certification programs have several options that will offer you the best knowledge.  By learning everything that you need to know about information technology you will be able to open new doors to your career and personal business desires.  IT Certification offers several vari
 

Neuro-linguistic Programming Methods

Neuro linguistic Programming Methods There are several methods used for performing Neuro linguistic Programming on an individual for obtaining insights into the psyche of the person in order to correct to modify certain patterns of behavior These techniques are also used for Neuro linguistic trainin
 

Importance of Proper English during Job Interview

Importance of Proper English during Job Interview Your job interview is crucially important and it will determine whether or not you will get the job Depending on the type of job you re going for it is very important for you to use proper English In most cases jobs which offer higher salaries will h
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape