Skip to content

Commit ebd15fe

Browse files
committed
Create problem6
1 parent ea7678e commit ebd15fe

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

problem6

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//By A. Divya, CSE
2+
KthElementIterative(struct node * root, int k)
3+
{
4+
struct node * temp = root;
5+
struct node * x;
6+
7+
push(root);
8+
temp = temp->left;
9+
10+
while( stack is not empty)
11+
{
12+
13+
while( temp ! = NULL)
14+
{
15+
push( temp );
16+
temp = temp ->left;
17+
}
18+
19+
x = pop();
20+
count ++;
21+
22+
if(count == k )
23+
break;
24+
25+
26+
if( x->right)
27+
{push(x-right);temp = x->right;}
28+
29+
else temp=null;
30+
31+
}
32+
33+
return x->data;
34+
}

0 commit comments

Comments
 (0)