<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>non-recursive | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/non-recursive/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Sun, 06 Feb 2011 10:46:51 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>Java program to print Fibonacci sequence Recursive &#038; Non Recursive</title>
		<link>https://studentprojects.in/software-development/java/java-programs/basic/java-program-print-fibonacci-sequence-recursive-recursive/</link>
					<comments>https://studentprojects.in/software-development/java/java-programs/basic/java-program-print-fibonacci-sequence-recursive-recursive/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Mon, 07 Feb 2011 10:44:27 +0000</pubDate>
				<category><![CDATA[Basic Programs]]></category>
		<category><![CDATA[fibonacci]]></category>
		<category><![CDATA[non-recursive]]></category>
		<category><![CDATA[Java]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1367</guid>

					<description><![CDATA[<p>The Fibonacci sequence is defined by the following rule. The first 2 values in the sequence are 1, 1. Every subsequent value is the sum of the 2 values preceding it. Write a Java program that uses both recursive and non-recursive functions to print the nth value of the Fibonacci sequence. /*Non Recursive Solution*/ import</p>
<p>The post <a href="https://studentprojects.in/software-development/java/java-programs/basic/java-program-print-fibonacci-sequence-recursive-recursive/">Java program to print Fibonacci sequence Recursive & Non Recursive</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>The Fibonacci sequence is defined by the following rule. The first 2 values in the sequence are 1, 1. Every subsequent value is the sum of the 2 values preceding it. Write a Java program that uses both recursive and non-recursive functions to print<br />
the nth value of the Fibonacci sequence.</p>
<pre lang="java" line="1">
/*Non Recursive Solution*/
import java.util.Scanner;
class Fib {
	public static void main(String args[ ]) {
		Scanner input=new Scanner(System.in);
		int i,a=1,b=1,c=0,t;
		System.out.println("Enter value of t:");
		t=input.nextInt();
		System.out.print(a);
		System.out.print(" "+b);
		for(i=0;i<t-2;i++) {
			c=a+b;
			a=b;
			b=c;
			System.out.print(" "+c);
		}
		System.out.println();
		System.out.print(t+"th value of the series is: "+c);
	}
}
</pre>
<pre lang="java" line="1">
/* Recursive Solution*/
import java.io.*;
import java.lang.*;
class Demo {
	int fib(int n) {
		if(n==1)
			return (1);
		else if(n==2)
			return (1);
		else
			return (fib(n-1)+fib(n-2));
	}
}
class RecFibDemo {
	public static void main(String args[])throws IOException {
		InputStreamReader obj=new InputStreamReader(System.in);
		BufferedReader br=new BufferedReader(obj);
		System.out.println("enter last number");
		int n=Integer.parseInt(br.readLine());
		Demo ob=new Demo();
		System.out.println("fibonacci series is as follows");
		int res=0;
		for(int i=1;i<=n;i++) {
			res=ob.fib(i);
			System.out.println(" "+res);
		}
		System.out.println();
		System.out.println(n+"th value of the series is "+res);
	}
}
</pre><p>The post <a href="https://studentprojects.in/software-development/java/java-programs/basic/java-program-print-fibonacci-sequence-recursive-recursive/">Java program to print Fibonacci sequence Recursive & Non Recursive</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/java/java-programs/basic/java-program-print-fibonacci-sequence-recursive-recursive/feed/</wfw:commentRss>
			<slash:comments>11</slash:comments>
		
		
			</item>
		<item>
		<title>C++ program that uses non-recursive functions to traverse a binary tree in In-order</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-that-uses-non-recursive-functions-to-traverse-a-binary-tree-in-in-order/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-that-uses-non-recursive-functions-to-traverse-a-binary-tree-in-in-order/#respond</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Thu, 11 Mar 2010 17:20:22 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<category><![CDATA[In-order]]></category>
		<category><![CDATA[binary tree]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[non-recursive]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[programs]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1030</guid>

					<description><![CDATA[<p>/* Write C++ program that uses non-recursive functions to traverse a binary tree in In-order */ #include #include #include using namespace std; class node { public: class node *left; class node *right; int data; }; class tree: public node { public: int stk[50],top; node *root; tree() { root=NULL; top=0; } void insert(int ch) { node</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-that-uses-non-recursive-functions-to-traverse-a-binary-tree-in-in-order/">C++ program that uses non-recursive functions to traverse a binary tree in In-order</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>/* Write C++ program that uses non-recursive functions to traverse a binary tree in In-order */</p>
<pre lang="pre">
#include<iostream>
#include<conio.h>
#include<stdlib.h>
using namespace std;
class node
{
public:
class node *left;
class node *right;
int data;
};

class tree: public node
{
public:
int stk[50],top;
node *root;
tree()
{
root=NULL;
top=0;
}
void insert(int ch)
{
	node *temp,*temp1;
	if(root== NULL)
	{
		root=new node;
		root->data=ch;
		root->left=NULL;
		root->right=NULL;
		return;
	}
	temp1=new node;
	temp1->data=ch;
	temp1->right=temp1->left=NULL;
	temp=search(root,ch);
	if(temp->data>ch)
		temp->left=temp1;
	else
		temp->right=temp1;

}

node *search(node *temp,int ch)
{
	if(root== NULL)
	{
		cout <<"no node present";
		return NULL;
	}
	if(temp->left==NULL && temp->right== NULL)
		return temp;

	if(temp->data>ch)
	     {  if(temp->left==NULL) return temp;
		search(temp->left,ch);}
	else
	      { if(temp->right==NULL) return temp;
	      search(temp->right,ch);

}              }

void display(node *temp)
{
	if(temp==NULL)
	    return ;
	display(temp->left); 
	cout<<temp->data;
	display(temp->right);
}
void inorder( node *root)
{
	node *p;
	p=root;
	top=0;
	do
	{
		while(p!=NULL)
		{
			stk[top]=p->data;
			top++;
			p=p->left;
		}
		if(top>0)
		{
			p=pop(root);
			cout << p->data;
			p=p->right;
		}
	}while(top!=0 || p!=NULL);
}


node * pop(node *p)
{
	int ch;
	ch=stk[top-1];
	if(p->data==ch)
	{
		top--;
		return p;
	}
	if(p->data>ch)
		pop(p->left);
	else
		pop(p->right);
}
};

main()
{
	tree t1;
	int ch,n,i;
	while(1)
	{
		cout <<"\n1.INSERT\n2.DISPLAY 3.INORDER TRAVERSE\n4.EXIT\nEnter your choice:";
		cin >> ch;
		switch(ch)
		{
		case 1:   cout <<"enter no of elements to insert:";
			  cin >> n;
			  for(i=1;i<=n;i++)
			  {  cin >> ch;
			     t1.insert(ch);
			  }
			   break;
		case 2:   t1.display(t1.root);break;
		case 3:   t1.inorder(t1.root); break;
		case 4:   exit(1);
		}
	}
}
</pre>
<p><strong>OUTPUT</strong></p>
<p>1.INSERT<br />
2.DISPLAY 3.INORDER TRAVERSE<br />
4.EXIT<br />
Enter your choice:1<br />
enter no of elements to inser<br />
5 24 36 11 44 2 21</p>
<p>1.INSERT<br />
2.DISPLAY 3.INORDER TRAVERSE<br />
4.EXIT<br />
Enter your choice:3<br />
251121243644</p>
<p>1.INSERT<br />
2.DISPLAY 3.INORDER TRAVERSE<br />
4.EXIT<br />
Enter your choice:3<br />
251121243644</p>
<p>1.INSERT<br />
2.DISPLAY 3.INORDER TRAVERSE<br />
4.EXIT<br />
Enter your choice:4</p><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-that-uses-non-recursive-functions-to-traverse-a-binary-tree-in-in-order/">C++ program that uses non-recursive functions to traverse a binary tree in In-order</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-that-uses-non-recursive-functions-to-traverse-a-binary-tree-in-in-order/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>C++ program that uses non-recursive functions to traverse a binary tree in Pre-order</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-that-uses-non-recursive-functions-to-traverse-a-binary-tree-in-pre-order/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-that-uses-non-recursive-functions-to-traverse-a-binary-tree-in-pre-order/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Thu, 11 Mar 2010 17:16:36 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<category><![CDATA[traverse]]></category>
		<category><![CDATA[Datastructure]]></category>
		<category><![CDATA[binary tree]]></category>
		<category><![CDATA[non-recursive]]></category>
		<category><![CDATA[C Programs]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1028</guid>

					<description><![CDATA[<p>/* Write C++ program that uses non-recursive functions to traverse a binary tree in Pre-order */ #include #include #include using namespace std; class node { public: class node *left; class node *right; int data; }; class tree: public node { public: int stk[50],top; node *root; tree() { root=NULL; top=0; } void insert(int ch) { node</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-that-uses-non-recursive-functions-to-traverse-a-binary-tree-in-pre-order/">C++ program that uses non-recursive functions to traverse a binary tree in Pre-order</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>/* Write C++ program that uses non-recursive functions to traverse a binary tree in Pre-order */</p>
<pre lang="cpp">
#include<iostream>
#include<conio.h>
#include<stdlib.h>
using namespace std;
class node
{
public:
class node *left;
class node *right;
int data;
};

class tree: public node
{
public:
int stk[50],top;
node *root;
tree()
{
root=NULL;
top=0;
}
void insert(int ch)
{
	node *temp,*temp1;
	if(root== NULL)
	{
		root=new node;
		root->data=ch;
		root->left=NULL;
		root->right=NULL;
		return;
	}
	temp1=new node;
	temp1->data=ch;
	temp1->right=temp1->left=NULL;
	temp=search(root,ch);
	if(temp->data>ch)
		temp->left=temp1;
	else
		temp->right=temp1;

}

node *search(node *temp,int ch)
{
	if(root== NULL)
	{
		cout <<"no node present";
		return NULL;
	}
	if(temp->left==NULL && temp->right== NULL)
		return temp;

	if(temp->data>ch)
	     {  if(temp->left==NULL) return temp;
		search(temp->left,ch);}
	else
	      { if(temp->right==NULL) return temp;
	      search(temp->right,ch);

}              }

void display(node *temp)
{
	if(temp==NULL)
	 return ;
	display(temp->left);
       cout<<temp->data <<" ";
	display(temp->right);
}
void preorder( node *root)
{
	node *p,*q;
	p=root;
	q=NULL;
	top=0;

	while(p!=NULL)
	{
		cout <<p->data  << " ";
		if(p->right!=NULL)
		{
			stk[top]=p->right->data;
			top++;
		}
		p=p->left;
		if(p==NULL && top>0)
	{
		p=pop(root);
	}
	}
}

node * pop(node *p)
{
int ch;
ch=stk[top-1];
if(p->data==ch)
{
top--;
return p;
}
if(p->data>ch)
pop(p->left);
else
pop(p->right);
}
};
main()
{
	tree t1;
	int ch,n,i;
	while(1)
	{
		cout <<"\n1.INSERT\n2.DISPLAY 3.PREORDER TRAVERSE\n4.EXIT\nEnter your choice:";
		cin >> ch;
		switch(ch)
		{
		case 1:   cout <<"enter no of elements to insert:";
			  cout<<"\n enter the elements";
			  cin >> n;
			  for(i=1;i<=n;i++)
			  {  cin >> ch;
			     t1.insert(ch);
			  }
			   break;
		case 2:   t1.display(t1.root);break;
		case 3:   t1.preorder(t1.root); break;
		case 4:   exit(1);
		}
	}
}
</pre>
<p><strong>OUTPUT</strong></p>
<p>1.INSERT<br />
2.DISPLAY 3.PREORDER TRAVERSE<br />
4.EXIT<br />
Enter your choice:1<br />
enter no of elements to insert<br />
 enter the elements7<br />
5 24 36 11 44 2 21</p>
<p>1.INSERT<br />
2.DISPLAY 3.PREORDER TRAVERSE<br />
4.EXIT<br />
Enter your choice:2<br />
2 5 11 21 24 36 44</p>
<p>1.INSERT<br />
2.DISPLAY 3.PREORDER TRAVERSE<br />
4.EXIT<br />
Enter your choice:3<br />
5 2 24 11 21 36 44</p>
<p>1.INSERT<br />
2.DISPLAY 3.PREORDER TRAVERSE<br />
4.EXIT<br />
Enter your choice:4</p><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-that-uses-non-recursive-functions-to-traverse-a-binary-tree-in-pre-order/">C++ program that uses non-recursive functions to traverse a binary tree in Pre-order</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-that-uses-non-recursive-functions-to-traverse-a-binary-tree-in-pre-order/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Java program to print Fibonacci sequence</title>
		<link>https://studentprojects.in/software-development/java/java-programs/basic/java-program-to-print-fibonacci-sequence/</link>
					<comments>https://studentprojects.in/software-development/java/java-programs/basic/java-program-to-print-fibonacci-sequence/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Fri, 02 Oct 2009 14:50:28 +0000</pubDate>
				<category><![CDATA[Basic Programs]]></category>
		<category><![CDATA[Java programs]]></category>
		<category><![CDATA[Fibonacci sequence]]></category>
		<category><![CDATA[non-recursive]]></category>
		<category><![CDATA[recursive]]></category>
		<category><![CDATA[recursion]]></category>
		<category><![CDATA[Java]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=850</guid>

					<description><![CDATA[<p>Write a Java program that uses both recursive and non-recursive functions to print nth value in the Fibonacci sequence.</p>
<p>The post <a href="https://studentprojects.in/software-development/java/java-programs/basic/java-program-to-print-fibonacci-sequence/">Java program to print Fibonacci sequence</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Write a Java program that uses both recursive and non-recursive functions to print nth value in the Fibonacci sequence</p>
<p><strong>Without recursion:</strong></p>
<pre lang="java" escaped="true" line="1">
import java.util.Scanner;
class fibonacci
{
	public static void main(String[] input)
	{
		int x,y;
		x=Integer.parseInt(input[0]);
		y=Integer.parseInt(input[1]);
		Scanner s=new Scanner(System.in);
		System.out.println(“Enter the value of n:”);
int n=s.nextInt();
		int z[]=new int[n];
		z[0]=x;
		z[1]=y;
		for(int i=2;i<n;i++)
		{
			z[i]=z[i-1]+z[i-2];
		}
		for(int i=0;i<n;i++)
		{	
			System.out.println(z[i]);
		}
	}
} 
</pre>
<p><strong>With recursion:</strong></p>
<pre lang="java" escaped="true" line="1">
import java.util.Scanner;
class fibonacci
{
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		System.out.println(“Enter the value of n:”);
		int n=s.nextInt();
		fiboni f1=new fiboni();
		System.out.println(f1.fibon(n));
	}
}
class fiboni
{
	public int fibon(int a)
	{
		if(a==0 || a==1)
			return 1;
		else
			return fibon(a-1)+fibon(a-2);
	}
}
</pre>
<p><strong>Output:</strong></p>
<p>10</p>
<p>1<br />
1<br />
2<br />
3<br />
5<br />
8<br />
13<br />
21<br />
34<br />
55</p><p>The post <a href="https://studentprojects.in/software-development/java/java-programs/basic/java-program-to-print-fibonacci-sequence/">Java program to print Fibonacci sequence</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/java/java-programs/basic/java-program-to-print-fibonacci-sequence/feed/</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
			</item>
	</channel>
</rss>
