<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8286439525414307195</id><updated>2026-06-16T18:20:22.233+05:30</updated><category term="bangalore address"/><category term="bangalore shop address"/><category term="bangalore shop location"/><category term="bangalore shop&#39;s address"/><category term="Coffee day outlets in india"/><category term="infosys Interview Questions and Answers"/><category term="wipro Interview Questions"/><category term=".mdi"/><category term=".mdi file"/><category term="Engineering and m tech projects"/><category term="Engineering fimal year projects"/><category term="Engineering projects"/><category term="How to prevent hair loss"/><category term="Karnataka Premier League schedule"/><category term="Rescuers start to recover bodies after Airbus comes down in Comoros archipelago"/><category term="google C hash Interview Questions and Answers"/><category term="h1n1"/><category term="h1n1 disies"/><category term="h1n1 virus"/><category term="ipl 2010 fixture"/><category term="ipl season 3 fixture"/><category term="ipl season 3 schedule"/><category term="m tech projects"/><category term="mdi file"/><category term="microsoft C hash Interview Questions and Answers"/><category term="microsoft interview questions"/><category term="what is h1n1"/><category term="what is h1n1 disies"/><category term=".Net Database Interview Questions and Answers"/><category term="10 tallest building in india"/><category term="100 rs coin"/><category term="100 rupees coin released"/><category term="100rs coin"/><category term="16-year-old Brooke Greenberg has not aged significantly"/><category term="24/7 roadside vehicle breakdown service - Kiosk"/><category term="27th Aug the Whole World is waiting for"/><category term="3"/><category term="4-yr-old lad cake walks accident"/><category term="5 things I wish some people wouldn&#39;t install on their PCs"/><category term="5530"/><category term="604 Coffee Cups to create Mona Lisa"/><category term="604 Coffee Cups to create the Mona Lisa"/><category term="604 Cups to create Mona Lisa"/><category term="604 Cups to create the Mona Lisa"/><category term="90 Congress and TDP MLA&#39;s resigned"/><category term="90 Congress and TDP MLA&#39;s resigned in andhra"/><category term="90 MLA&#39;s resigned"/><category term="90 MLA&#39;s resigned in andhra"/><category term="A/B and Multivariate Testing for All"/><category term="ANDROID MOBILE"/><category term="ANDROID cell phones"/><category term="ANDROID cellphones"/><category term="ASUS and Toshiba wins Laptop reliability survey"/><category term="Add another 9 to your mobile number in Jan"/><category term="After stroke"/><category term="After stroke treatment"/><category term="Aircel"/><category term="Aircel  munbai"/><category term="Aircel  pune"/><category term="Aircel Ahmedabad"/><category term="Aircel Coimbatore"/><category term="Aircel Corporate Headquarters"/><category term="Aircel bangalore"/><category term="Aircel chennai"/><category term="Aircel cochin"/><category term="Aircel hyderabad"/><category term="Aircel india"/><category term="Aircel kolkata"/><category term="Airtel chennai"/><category term="Airtel madras"/><category term="Airtel mangalore"/><category term="Apple stores in bangalore"/><category term="Apple stores in chennai"/><category term="Apple stores in india"/><category term="Apple stores in mumbai"/><category term="Ares I-X rocket"/><category term="Automobiles"/><category term="Ayurvedic medicine for swine flu"/><category term="BLOOD TYPE DIET"/><category term="Bacon Lip Balm"/><category term="Bajaj auto service centers in bangalore"/><category term="Bajaj service centers"/><category term="Bajaj service centers in bangalore"/><category term="Bangalore Brigaders"/><category term="Bangalore Ganesh Utsav 2010 schedule"/><category term="Bangalore Traffic Song"/><category term="Bangalore Traffic video"/><category term="Bangalore Traffic video Song"/><category term="Bangalores premier 24/7 roadside vehicle breakdown service"/><category term="Banking Trojan"/><category term="Banks"/><category term="Barney Frank"/><category term="Batch Export"/><category term="Belgaavi Panthers"/><category term="Best Add Placement Strategy for Google AdSense"/><category term="Best Add Placement Strategy for blog"/><category term="Best Add Placement Strategy for website"/><category term="Bhagavad Gita in Urdu"/><category term="Bhagavad Githa in Urdu"/><category term="BhagavadGita in Urdu"/><category term="BhagavadGitha in Urdu"/><category term="Bijapur Bulls"/><category term="Bin Laden&#39;s audio message appears online"/><category term="Bin Laden&#39;s audio tape"/><category term="Bin Laden&#39;s message appears online"/><category term="Bing Copying Kayak"/><category term="Booster Applications for Windows 7"/><category term="Burger King &#39;Super Seven Incher&#39;"/><category term="Burger King Super Seven Incher"/><category term="CRICKET"/><category term="Champions League 20/20 2010 fixture"/><category term="Champions League Teams"/><category term="Champions League Twenty  Twenty  2010 fixture"/><category term="Champions league cricket schedule"/><category term="Cheap TG01"/><category term="Chief Minister&#39;s of Karnataka"/><category term="Chief Ministers of Karnataka"/><category term="China and Macau to develop island"/><category term="China mobile gprs setting"/><category term="China to develop island"/><category term="Chrome cloud synchronization"/><category term="Classic Cinema Online Streams Free Classic Films"/><category term="Clix handset"/><category term="Computers/IT"/><category term="Couriers"/><category term="Cricket World cup 2011 Fixtures"/><category term="Cricket World cup 2011 schedule"/><category term="Cross-Platform GTD Task Management App"/><category term="Cure for h1n1"/><category term="DHL Delivers Space Spectrometer To Russia"/><category term="DHL Delivers Space-Spectrometer To Russia"/><category term="DSP Programs"/><category term="DSP program to find the IDFT"/><category term="Dalai Lama"/><category term="Dalai Lama is eager to visit"/><category term="Daya Nayak gets Clean Chit"/><category term="Daya nayak will be back soon"/><category term="DayaNayak gets Clean Chit"/><category term="Dayanayak will be back soon"/><category term="Diamonds"/><category term="Difference Between GETDATE() and GETUTCDATE()"/><category term="Digital Tattoo"/><category term="Digital Tattoo Interface Turns Your Skin Into A Display"/><category term="Distance between Bangalore and places"/><category term="Distance from Bangalore to different places"/><category term="Distance from Bangalore to other places"/><category term="Doctors Baffled"/><category term="Doit.im a Cross-Platform GTD Task Management App"/><category term="Dr Conrad Murray questioned"/><category term="Earth&#39;s magnetic field is moving"/><category term="Earth&#39;s north magnetic pole is racing toward Russia"/><category term="Eating a Burger King &#39;Super Seven Incher&#39;"/><category term="Eating a Burger King &#39;Super Seven Incher&#39; Is Just Like Giving a Blow Job [Advertising]"/><category term="Eddelu Manjunatha trailer"/><category term="Eddelu Manjunatha video"/><category term="Eigg quick mail service"/><category term="Eucalyptus oil  swine flu"/><category term="Eucalyptus oil can help in swine flu prevention"/><category term="Eucalyptus oil for swine flu"/><category term="FT resistive touch screen"/><category term="FT resistive touchscreen"/><category term="Facebook Users Targeted By Banking Trojan"/><category term="Fake orkut id of Amulya"/><category term="Fake orkut profile of Amulya"/><category term="Fake profile of amulya"/><category term="Fart"/><category term="Fascinating and astonishing facts of life and nature"/><category term="Finance"/><category term="Fishing puts a third of species at risk"/><category term="Frank Introduces Legislation To Decriminalize Marijuana"/><category term="Free Classic Films streaming in Classic Cinema Online"/><category term="Free antivirus from microsfot"/><category term="Funny Print Ads"/><category term="Funny images"/><category term="Google Chrome Portable"/><category term="Google Docs Batch Export"/><category term="Google Releases API for Website Optimizer"/><category term="Google releases Wave protocol implementation source code"/><category term="Google reveals plans for Chrome cloud synchronization"/><category term="Government office links"/><category term="Government office related links"/><category term="H1N1symptoms"/><category term="HP fails in Laptop reliability survey"/><category term="HTC"/><category term="HTC Touch Pro2"/><category term="HTC Touch Pro2 (T7373). HTC Touch"/><category term="HTC Touch Pro2(T7373)"/><category term="Haagen Dazs"/><category term="Hair"/><category term="Hair loss"/><category term="Healthcare"/><category term="Help to poor students"/><category term="Hero honda service centers in bangalore"/><category term="History for 10th December"/><category term="History for 10th February"/><category term="History for 10th January"/><category term="History for 10th November"/><category term="History for 11th December"/><category term="History for 11th February"/><category term="History for 11th January"/><category term="History for 11th November"/><category term="History for 12th December"/><category term="History for 12th February"/><category term="History for 12th January"/><category term="History for 12th November"/><category term="History for 13th December"/><category term="History for 13th February"/><category term="History for 13th January"/><category term="History for 13th November"/><category term="History for 14th December"/><category term="History for 14th February"/><category term="History for 14th January"/><category term="History for 14th November"/><category term="History for 15th December"/><category term="History for 15th February"/><category term="History for 15th January"/><category term="History for 15th November"/><category term="History for 16th December"/><category term="History for 16th February"/><category term="History for 16th January"/><category term="History for 16th November"/><category term="History for 17th December"/><category term="History for 17th February"/><category term="History for 17th January"/><category term="History for 17th November"/><category term="History for 18th December"/><category term="History for 18th February"/><category term="History for 18th January"/><category term="History for 18th November"/><category term="History for 19th December"/><category term="History for 19th February"/><category term="History for 19th January"/><category term="History for 19th November"/><category term="History for 1st December"/><category term="History for 1st February"/><category term="History for 1st January"/><category term="History for 1st November"/><category term="History for 20th December"/><category term="History for 20th January"/><category term="History for 20th November"/><category term="History for 21st December"/><category term="History for 21st January"/><category term="History for 21st November"/><category term="History for 22nd December"/><category term="History for 22nd January"/><category term="History for 22nd November"/><category term="History for 23rd December"/><category term="History for 23rd January"/><category term="History for 23rd November"/><category term="History for 24th December"/><category term="History for 24th January"/><category term="History for 24th November"/><category term="History for 25th December"/><category term="History for 25th January"/><category term="History for 25th November"/><category term="History for 26th December"/><category term="History for 26th January"/><category term="History for 26th November"/><category term="History for 27th December"/><category term="History for 27th January"/><category term="History for 27th November"/><category term="History for 28th December"/><category term="History for 28th January"/><category term="History for 28th November"/><category term="History for 29th December"/><category term="History for 29th January"/><category term="History for 29th November"/><category term="History for 2nd December"/><category term="History for 2nd February"/><category term="History for 2nd January"/><category term="History for 2nd November"/><category term="History for 30th December"/><category term="History for 30th January"/><category term="History for 30th November"/><category term="History for 31st December"/><category term="History for 31st January"/><category term="History for 3rd December"/><category term="History for 3rd February"/><category term="History for 3rd January"/><category term="History for 3rd November"/><category term="History for 4th December"/><category term="History for 4th February"/><category term="History for 4th January"/><category term="History for 4th November"/><category term="History for 5th December"/><category term="History for 5th February"/><category term="History for 5th January"/><category term="History for 5th November"/><category term="History for 6th December"/><category term="History for 6th February"/><category term="History for 6th January"/><category term="History for 6th November"/><category term="History for 7th December"/><category term="History for 7th February"/><category term="History for 7th January"/><category term="History for 7th November"/><category term="History for 8th December"/><category term="History for 8th February"/><category term="History for 8th January"/><category term="History for 8th November"/><category term="History for 9th December"/><category term="History for 9th February"/><category term="History for 9th January"/><category term="History for 9th November"/><category term="History for December 10th"/><category term="History for December 11th"/><category term="History for December 12th"/><category term="History for December 13th"/><category term="History for December 14th"/><category term="History for December 15th"/><category term="History for December 16th"/><category term="History for December 17th"/><category term="History for December 18th"/><category term="History for December 19th"/><category term="History for December 1st"/><category term="History for December 20th"/><category term="History for December 21st"/><category term="History for December 22nd"/><category term="History for December 23rd"/><category term="History for December 24th"/><category term="History for December 25th"/><category term="History for December 26th"/><category term="History for December 27th"/><category term="History for December 28th"/><category term="History for December 29th"/><category term="History for December 2nd"/><category term="History for December 30th"/><category term="History for December 31st"/><category term="History for December 3rd"/><category term="History for December 4th"/><category term="History for December 5th"/><category term="History for December 6th"/><category term="History for December 7th"/><category term="History for December 8th"/><category term="History for December 9th"/><category term="History for February 10th"/><category term="History for February 11th"/><category term="History for February 12th"/><category term="History for February 13th"/><category term="History for February 14th"/><category term="History for February 15th"/><category term="History for February 16th"/><category term="History for February 17th"/><category term="History for February 18th"/><category term="History for February 19th"/><category term="History for February 1st"/><category term="History for February 2nd"/><category term="History for February 3rd"/><category term="History for February 4th"/><category term="History for February 5th"/><category term="History for February 6th"/><category term="History for February 7th"/><category term="History for February 8th"/><category term="History for February 9th"/><category term="History for January 10th"/><category term="History for January 11th"/><category term="History for January 12th"/><category term="History for January 13th"/><category term="History for January 14th"/><category term="History for January 15th"/><category term="History for January 16th"/><category term="History for January 17th"/><category term="History for January 18th"/><category term="History for January 19th"/><category term="History for January 1st"/><category term="History for January 20th"/><category term="History for January 21st"/><category term="History for January 22nd"/><category term="History for January 23rd"/><category term="History for January 24th"/><category term="History for January 25th"/><category term="History for January 26th"/><category term="History for January 27th"/><category term="History for January 28th"/><category term="History for January 29th"/><category term="History for January 2nd"/><category term="History for January 30th"/><category term="History for January 31st"/><category term="History for January 3rd"/><category term="History for January 4th"/><category term="History for January 5th"/><category term="History for January 6th"/><category term="History for January 7th"/><category term="History for January 8th"/><category term="History for January 9th"/><category term="History for November 10th"/><category term="History for November 11th"/><category term="History for November 12th"/><category term="History for November 13th"/><category term="History for November 14th"/><category term="History for November 15th"/><category term="History for November 16th"/><category term="History for November 17th"/><category term="History for November 18th"/><category term="History for November 19th"/><category term="History for November 1st"/><category term="History for November 20th"/><category term="History for November 21st"/><category term="History for November 22nd"/><category term="History for November 23rd"/><category term="History for November 24th"/><category term="History for November 25th"/><category term="History for November 26th"/><category term="History for November 27th"/><category term="History for November 28th"/><category term="History for November 29th"/><category term="History for November 2nd"/><category term="History for November 30th"/><category term="History for November 3rd"/><category term="History for November 4th"/><category term="History for November 5th"/><category term="History for November 6th"/><category term="History for November 7th"/><category term="History for November 8th"/><category term="History for November 9th"/><category term="History of 10th December"/><category term="History of 10th February"/><category term="History of 10th January"/><category term="History of 10th November"/><category term="History of 11th December"/><category term="History of 11th February"/><category term="History of 11th January"/><category term="History of 11th November"/><category term="History of 12th December"/><category term="History of 12th February"/><category term="History of 12th January"/><category term="History of 12th November"/><category term="History of 13th December"/><category term="History of 13th February"/><category term="History of 13th January"/><category term="History of 13th November"/><category term="History of 14th December"/><category term="History of 14th February"/><category term="History of 14th January"/><category term="History of 14th November"/><category term="History of 15th December"/><category term="History of 15th February"/><category term="History of 15th January"/><category term="History of 15th November"/><category term="History of 16th December"/><category term="History of 16th February"/><category term="History of 16th January"/><category term="History of 16th November"/><category term="History of 17th December"/><category term="History of 17th February"/><category term="History of 17th January"/><category term="History of 17th November"/><category term="History of 18th December"/><category term="History of 18th February"/><category term="History of 18th January"/><category term="History of 18th November"/><category term="History of 19th December"/><category term="History of 19th February"/><category term="History of 19th January"/><category term="History of 19th November"/><category term="History of 1st December"/><category term="History of 1st February"/><category term="History of 1st January"/><category term="History of 1st November"/><category term="History of 20th December"/><category term="History of 20th January"/><category term="History of 20th November"/><category term="History of 21st December"/><category term="History of 21st January"/><category term="History of 21st November"/><category term="History of 22nd December"/><category term="History of 22nd January"/><category term="History of 22nd November"/><category term="History of 23rd December"/><category term="History of 23rd January"/><category term="History of 23rd November"/><category term="History of 24th December"/><category term="History of 24th January"/><category term="History of 24th November"/><category term="History of 25th December"/><category term="History of 25th January"/><category term="History of 25th November"/><category term="History of 26th December"/><category term="History of 26th January"/><category term="History of 26th November"/><category term="History of 27th December"/><category term="History of 27th January"/><category term="History of 27th November"/><category term="History of 28th December"/><category term="History of 28th January"/><category term="History of 28th November"/><category term="History of 29th December"/><category term="History of 29th January"/><category term="History of 29th November"/><category term="History of 2nd December"/><category term="History of 2nd February"/><category term="History of 2nd January"/><category term="History of 2nd November"/><category term="History of 30th December"/><category term="History of 30th January"/><category term="History of 30th November"/><category term="History of 31st December"/><category term="History of 31st January"/><category term="History of 3rd December"/><category term="History of 3rd February"/><category term="History of 3rd January"/><category term="History of 3rd November"/><category term="History of 4th December"/><category term="History of 4th February"/><category term="History of 4th January"/><category term="History of 4th November"/><category term="History of 5th December"/><category term="History of 5th February"/><category term="History of 5th January"/><category term="History of 5th November"/><category term="History of 6th December"/><category term="History of 6th February"/><category term="History of 6th January"/><category term="History of 6th November"/><category term="History of 7th December"/><category term="History of 7th February"/><category term="History of 7th January"/><category term="History of 7th November"/><category term="History of 8th December"/><category term="History of 8th February"/><category term="History of 8th January"/><category term="History of 8th November"/><category term="History of 9th December"/><category term="History of 9th February"/><category term="History of 9th January"/><category term="History of 9th November"/><category term="History of December 10th"/><category term="History of December 11th"/><category term="History of December 12th"/><category term="History of December 13th"/><category term="History of December 14th"/><category term="History of December 15th"/><category term="History of December 16th"/><category term="History of December 17th"/><category term="History of December 18th"/><category term="History of December 19th"/><category term="History of December 1st"/><category term="History of December 20th"/><category term="History of December 21st"/><category term="History of December 22nd"/><category term="History of December 23rd"/><category term="History of December 24th"/><category term="History of December 25th"/><category term="History of December 26th"/><category term="History of December 27th"/><category term="History of December 28th"/><category term="History of December 29th"/><category term="History of December 2nd"/><category term="History of December 30th"/><category term="History of December 31st"/><category term="History of December 3rd"/><category term="History of December 4th"/><category term="History of December 5th"/><category term="History of December 6th"/><category term="History of December 7th"/><category term="History of December 8th"/><category term="History of December 9th"/><category term="History of February 10th"/><category term="History of February 11th"/><category term="History of February 12th"/><category term="History of February 13th"/><category term="History of February 14th"/><category term="History of February 15th"/><category term="History of February 16th"/><category term="History of February 17th"/><category term="History of February 18th"/><category term="History of February 19th"/><category term="History of February 1st"/><category term="History of February 2nd"/><category term="History of February 3rd"/><category term="History of February 4th"/><category term="History of February 5th"/><category term="History of February 6th"/><category term="History of February 7th"/><category term="History of February 8th"/><category term="History of February 9th"/><category term="History of January 10th"/><category term="History of January 11th"/><category term="History of January 12th"/><category term="History of January 13th"/><category term="History of January 14th"/><category term="History of January 15th"/><category term="History of January 16th"/><category term="History of January 17th"/><category term="History of January 18th"/><category term="History of January 19th"/><category term="History of January 1st"/><category term="History of January 20th"/><category term="History of January 21st"/><category term="History of January 22nd"/><category term="History of January 23rd"/><category term="History of January 24th"/><category term="History of January 25th"/><category term="History of January 26th"/><category term="History of January 27th"/><category term="History of January 28th"/><category term="History of January 29th"/><category term="History of January 2nd"/><category term="History of January 30th"/><category term="History of January 31st"/><category term="History of January 3rd"/><category term="History of January 4th"/><category term="History of January 5th"/><category term="History of January 6th"/><category term="History of January 7th"/><category term="History of January 8th"/><category term="History of January 9th"/><category term="History of November 10th"/><category term="History of November 11th"/><category term="History of November 12th"/><category term="History of November 13th"/><category term="History of November 14th"/><category term="History of November 15th"/><category term="History of November 16th"/><category term="History of November 17th"/><category term="History of November 18th"/><category term="History of November 19th"/><category term="History of November 1st"/><category term="History of November 20th"/><category term="History of November 21st"/><category term="History of November 22nd"/><category term="History of November 23rd"/><category term="History of November 24th"/><category term="History of November 25th"/><category term="History of November 26th"/><category term="History of November 27th"/><category term="History of November 28th"/><category term="History of November 29th"/><category term="History of November 2nd"/><category term="History of November 30th"/><category term="History of November 3rd"/><category term="History of November 4th"/><category term="History of November 5th"/><category term="History of November 6th"/><category term="History of November 7th"/><category term="History of November 8th"/><category term="History of November 9th"/><category term="Home Appliances"/><category term="Home Remedies for Swine Flu"/><category term="Hotel Reservations"/><category term="How to Stop Hair Loss"/><category term="How to Stop Hair fall"/><category term="How to get New IMEI Number For Your Chinese Mobile"/><category term="How to join nasa"/><category term="How to prevent Hair fall"/><category term="How to protect hair"/><category term="How to type Rupee Symbol in Key board"/><category term="I feel like I am the princess of Udaipur"/><category term="ICC Announced That Sachin Tendulkar&#39;s Birthday will be Celebrated as World Cricket Day"/><category term="IIT starting online teaching"/><category term="IIT&#39;s starting online teaching"/><category term="IMEI number implanetd after November 30 will not work"/><category term="ITG XP Phone"/><category term="Idea Bangalore"/><category term="Idea sim card dealers"/><category term="India to get 11 digit mobile numbers in jan"/><category term="India to get 11-digit mobile numbers in 2010"/><category term="India to host 29 matches"/><category term="India will host 29 matches"/><category term="Indian Rupee Symbol approved by Cabinet"/><category term="Indians not allowed"/><category term="Insurance"/><category term="Inter-frequency hard handoff and establishing the hard handoff environment"/><category term="Internship in nasa"/><category term="Intrigued by Girl Who Doesn&#39;t Age"/><category term="Investments"/><category term="J and D&#39;s"/><category term="J and D&#39;s Bacon Lip Balm"/><category term="J and D&#39;s Lip Balm"/><category term="Janmashtami"/><category term="Japan lauched a blue beer"/><category term="Japan recently lauched a blue beer"/><category term="Java enabled china mobile"/><category term="Just maat maatalli movie review"/><category term="Just maat maathalli movie review"/><category term="Just maath maatalli movie review"/><category term="Just maath maathalli movie review"/><category term="Just math maathalli movie review"/><category term="KPL  bidding details"/><category term="KPL live scorecard"/><category term="KPL players bidding details"/><category term="KPL scorecard"/><category term="KPL team names"/><category term="KSRTC launched Sleeper coach bus"/><category term="Kannada Album by Sonu"/><category term="Kannada Album by Sonu Nigam"/><category term="Kannada Links"/><category term="Kannada movie pruthvi songs download"/><category term="Kannada movie super box office collection"/><category term="Karbon Mobiles  Website"/><category term="Karbon Mobiles official Website"/><category term="Karnataka Premier League"/><category term="Karnataka Premier League 2009"/><category term="Karnataka Premier League live scorecard"/><category term="Karnataka Premier League scorecard"/><category term="Karnataka Premier League team owners"/><category term="Kayak to Bing Stop Copying Us"/><category term="Krishna Janmashtami"/><category term="Laptop reliability survey 2009"/><category term="Large quantity of water found on the Moon"/><category term="Last call from michael jakson home"/><category term="Last call from michael jakson house"/><category term="Last call from michael jaksons home"/><category term="Last call from michael jaksons house"/><category term="Like Draupadi in Mahabharata"/><category term="Lip Balm"/><category term="List of Ayyappa Temples in Abroad"/><category term="List of Ayyappa Temples in India"/><category term="Lord Venkateswara"/><category term="MH907"/><category term="MICHAEL JACKSON&#39;S DEAD BODY"/><category term="MICHAEL JACKSON&#39;S DEAD BODY VIDEO"/><category term="MICHAEL JACKSONS DEAD BODY"/><category term="MICHAEL JACKSONS DEAD BODY VIDEO"/><category term="MSE"/><category term="MSE download"/><category term="MSN launches free streaming video"/><category term="Mahindra Satyam"/><category term="Make Your Inbox Personal by mozilla"/><category term="Make Yourself Eligible for an Office 2010 Starter Beta"/><category term="Maleyali Jotheyali is a feast to the senses"/><category term="Maleyali Jotheyali is too good"/><category term="Maleyali Jotheyali kannada movie review"/><category term="Maleyali Jotheyali movie review"/><category term="Malik get one-year bans"/><category term="Malnad Gladiators"/><category term="Mangalore"/><category term="Matlab program to find the IDFT"/><category term="Matte Mungaru film Review"/><category term="Matte Mungaru kannada Movie Review"/><category term="Matte Mungaru kannada film Review"/><category term="Maya calendar"/><category term="Michael Jacksons doctor found"/><category term="Michael Jackson’s doctor disappeared"/><category term="Michael Jackson’s doctor found"/><category term="Michael Jackson’s doctor had given extensive interview"/><category term="Microsoft Security Essentials antivirus"/><category term="Microsoft Security Essentials antivirus download"/><category term="Microsoft announces free antivirus"/><category term="Microsoft has announced a UK service that will stream full-length videos of television shows for free"/><category term="Microsoft launches free streaming video"/><category term="Microsoft&#39;s Bing goes visual"/><category term="Microsoft&#39;s Bing.com goes visual"/><category term="Mobile"/><category term="Mobile Phone Runs On Windows XP"/><category term="Mobile Software"/><category term="Mobile Softwares"/><category term="Most waited kannada film spuer is ready to release on December 3rd"/><category term="Motion Activated Headphones Sony Ericsson"/><category term="Motorola Clix handset"/><category term="Motorola banks on new Clix handset"/><category term="Motorola&#39;s Clix handset"/><category term="Mozilla’s Raindrop Makes Your Inbox Personal"/><category term="Mozilla’s Raindrop Makes Your Inbox Personal Again"/><category term="Mysore Maharajas"/><category term="NASA  plans high explosion in moon"/><category term="NASA has plans to fire a rocket into the moon to create a six-mile high explosion"/><category term="NASA plans to fire a rocket into the moon"/><category term="NATO and Russia"/><category term="NYTimes and Wikipedia Save Reporter’s Life By NOT Reporting On His Capture"/><category term="Nasa assembles Ares test rocket"/><category term="Nasa assembles new test rocket"/><category term="Nasa&#39;s next-generation space transportation system"/><category term="New 100rs coin"/><category term="New Google Music Search"/><category term="New HTC Touch Pro2"/><category term="New York Times reporter David Rohde escaped from a Taliban prison"/><category term="New York Times reporter escaped from a Taliban prison"/><category term="New enhanced Google Music Search"/><category term="New symbol for indian rupee"/><category term="Nilgiri oil can help in swine flu prevention"/><category term="Nilgiri oil for swine flu"/><category term="Nilgiri oil swine flu"/><category term="Nivio to launch desktops for 3000 rs"/><category term="Nivio to launch desktops for 3000rs"/><category term="Nivio to launch desktops for 3k"/><category term="Nokia 5230 cell phone price in india"/><category term="Nokia 5230 cell phone review"/><category term="Nonpersistent and Persistent Connections"/><category term="North Magnetic Pole Moving Due to Core Flux"/><category term="Now iPhone 3G for 99 dollars"/><category term="Numerology"/><category term="Office 2010 Starter Beta"/><category term="Oli Lemieux practicing video"/><category term="One dress 365 days"/><category term="One dress one year"/><category term="Opportunities for students in nasa"/><category term="Opportunities in nasa"/><category term="Osama bin Laden warns Barack Obama"/><category term="Our upcoming Engineer-Pramod"/><category term="PVenkatesh Prasad and Robin Singh have been sacked"/><category term="Packers and Movers"/><category term="Pakistan cricket team captan Younis Khan and coach Intikhab Alam were suspended"/><category term="Pakistan cricket team captan Younis Khan suspended"/><category term="Persistent and Nonpersistent Connections"/><category term="Pinch zoom mobiles"/><category term="Pinch zooming for any Mobile"/><category term="Pinch zooming for any Mobile with resistive screen"/><category term="Portable Google Chrome"/><category term="Prasad and Robin sacked from coaching"/><category term="Principles of cellular frequency reuse"/><category term="Procedure to connect sata hard disk to pc"/><category term="Procedure to install sata hard disk to pc"/><category term="Programs That Can Makes Computer Faster"/><category term="Programs That Can Makes Your Computer Faster"/><category term="Provident Bangalore"/><category term="Raam movie review"/><category term="Radhika delivers a baby girl"/><category term="Rakhi Sawant"/><category term="Rakhi Sawant is marrying 16 members"/><category term="Ram movie review"/><category term="Ramcharan Teja&#39;s Orange RELEASE DATE"/><category term="Rana"/><category term="Reality about YSR"/><category term="Records Held by Sachin Tendulkar"/><category term="Reddy presented diamond crown"/><category term="Reddy presented diamond-studded crown"/><category term="Retina display"/><category term="Richards quashes Pakistani Qasim Umar&#39;s drug charge"/><category term="Richards quashes Qasim Umar"/><category term="Richards quashes Umar"/><category term="Russia can sway Iran&#39;s nuclear ambitions"/><category term="Russia can sway Irans nuclear ambitions"/><category term="Russia restart ties despite Georgia row"/><category term="Russia-NATO"/><category term="SMS bursts that can give a hacker complete power over iphone"/><category term="Sachin Tendulkar completed 17000 runs in ODI"/><category term="Sachin Tendulkar&#39;s Birthday will be Celebrated as World Cricket Day"/><category term="Sachin completed 17000 runs in ODI"/><category term="Samsung P1000 Galaxy Tab video"/><category term="Satellite Transponder Communications Link"/><category term="Satyam"/><category term="Satyam is now Mahindra Satyam"/><category term="See it to believe it"/><category term="See it to believe it 4-yr-old lad cake walks accident"/><category term="See it to believe it: 4-yr-old lad cake walks accident"/><category term="Sensitive Areas in Bangalore"/><category term="Shamanur Davangere"/><category term="Shoaib Malik and Rana Naved-ul-Hasan have been banned for a year"/><category term="Sleeper coach bus from KSRTC"/><category term="SoCal&#39;s New Floating Airport"/><category term="Software"/><category term="Software unlock for iPhone 4 is out"/><category term="Softwares"/><category term="Some home remedies for swine flu"/><category term="Sonia Gandhi&#39;s name is nominated for Nobel Peace Award 2009"/><category term="Sonia Gandhi&#39;s name is nominated for nobel award"/><category term="Sonia Gandhi&#39;s name is recommended for nobel award"/><category term="Sonu nigam to do a Kannada album"/><category term="Sonu nigams kannada album"/><category term="Sonu nigams’s kannada album is ready to release"/><category term="Sonu nigam’s kannada album"/><category term="Space Spectrometer in Russia"/><category term="Sriraman lost his helmet"/><category term="Suicide bomber in Russia"/><category term="Suicide bomber kills 19 in Russia"/><category term="Suicide bomber kills 19 in Russia&#39;s"/><category term="Suicide bomber kills 19 in Russia&#39;s Ingushetia"/><category term="Sun TV Network has acquired the broadcast rights for kpl"/><category term="Sun TV to broadcast kpl"/><category term="Super LCD"/><category term="Supplements for swine flu"/><category term="Suryakaanthi movie review"/><category term="Suryakanthi kannada movie review"/><category term="Suryakanthi movie review"/><category term="Suryakanthi review"/><category term="Swine Flu Home Remedies"/><category term="Symbian 3 video"/><category term="Symbian3 video"/><category term="Symbian^3 video"/><category term="T20"/><category term="T20 WORLD CUP"/><category term="T20 WORLD CUP 2009"/><category term="T20 worldcup semifinal"/><category term="TWENTY TWENTY"/><category term="TWENTY TWENTY WORLD CUP"/><category term="Taiwan challenging China"/><category term="Taiwan challenging China to let Dalai Lama visit"/><category term="Taslima Nasreen article on burqa"/><category term="Tata docomo"/><category term="Tata docomo Kerala"/><category term="Tata docomo Orissa"/><category term="Tata docomo Tamil Nadu"/><category term="Tata docomo bangalore"/><category term="Tata docomo chennai"/><category term="Tata docomo delhi"/><category term="Tata docomo hydrabad"/><category term="Tata docomo karnataka"/><category term="Tata docomo outlets"/><category term="The First Motion Activated Headphones"/><category term="The NATO-Russia Council is now back in gear"/><category term="The Quran does prescribe purdah"/><category term="The thrilling potential of &#39;SixthSense&#39; technology"/><category term="The thrilling potential of SixthSense technology"/><category term="Things I wish some people wouldn&#39;t install on their PCs"/><category term="Thulasi Can Keep Swine Flu AWAY"/><category term="Thulsi can help keep swine flu away"/><category term="Toll Free Numbers"/><category term="Toll Free Numbers in india"/><category term="Top 10 advanced features of SQL Server 2005"/><category term="Top 10 tallest building in india"/><category term="Traditional Chinese medicine for H1N1"/><category term="Traditional medicine for H1N1"/><category term="Traffic Song"/><category term="Travel"/><category term="Tulasi Can Keep Swine Flu AWAY"/><category term="Tulsi can help keep swine flu away"/><category term="Two Moons"/><category term="Two Moons never see in Your Life"/><category term="Two moons on 27th August"/><category term="US kids version of Ramayan"/><category term="US version of Ramayan"/><category term="USA kids version of Ramayan"/><category term="Udaya TV to broadcast Karnataka Premier League"/><category term="Underwater Train Will Take You to SoCal&#39;s New Floating Airport"/><category term="Underwater Train to SoCal&#39;s New Floating Airport"/><category term="Underwater Train to SoCal&#39;s new Airport"/><category term="Uninor Customer Care Numbers"/><category term="Uninor mobile Customer Care Numbers"/><category term="Uninor offices in Bihar"/><category term="Uninor offices in Chennai"/><category term="Uninor offices in bangalore"/><category term="Uninor offices in hydrabad"/><category term="Uninor offices in india"/><category term="Uninor offices in mumbai"/><category term="Upendra back to direction"/><category term="Upendra film shooting to start from Feb 17th"/><category term="Upendra is back to direction"/><category term="Upendra&#39;s film shooting to start from 17th feb"/><category term="Upendra&#39;s film shooting to start from Feb 17th"/><category term="Upendra&#39;s super box office collection"/><category term="Using Common Table Expressions"/><category term="Using Common Table Expressions in Sql server 2005"/><category term="Viv Richards thinks about Pakistani Qasim Umar&#39;s drug charge"/><category term="Viv Richards used to take drugs"/><category term="WANTED boys and girls for Uppi&#39;s new film super"/><category term="WORLD CUP"/><category term="WORLD CUP 2009"/><category term="Wave protocol from google"/><category term="Wave protocol source code"/><category term="Wave protocol source code from google"/><category term="What  team need to do to qualify for the ICC World Twenty20 semi-finals"/><category term="What are the new data types or enhanced data types in SQL Server 2005"/><category term="What india West Indies team need to do to qualify for the ICC World Twenty20 semifinals"/><category term="What is Janmashtami"/><category term="What is Krishna Janmashtami"/><category term="What is Navrathri festival"/><category term="What is Navratri festival"/><category term="What is ganesha chathurthi"/><category term="What is ganesha chaturthi"/><category term="What was the world&#39;s first mobile phone"/><category term="What&#39;s Eating Your Hard Drive Space"/><category term="Which is best screen among Super AMOLED"/><category term="Why doesn&#39;t she age"/><category term="Windows 7 Booster Applications"/><category term="Windows XP mobile"/><category term="Women&#39;s T20 semifinal"/><category term="Women&#39;s T20 worldcup semifinal"/><category term="World Currency Notes"/><category term="World Currency Notes images"/><category term="World Currency images"/><category term="World’s First Mobile Phone Runs On Windows XP"/><category term="YSR secrets"/><category term="Yemeni plane crashes"/><category term="Yemeni plane crashes in Indian Ocean"/><category term="Yemeni plane with 150 on board crashes in Indian Ocean"/><category term="Younis Khan Drops Catch in Semi Final of Champions Trophy"/><category term="Younis Khan Drops Catch in Semi Final video"/><category term="Younis Khan Drops Crucial Catch in Semi Final of Champions Trophy 2009"/><category term="Younis and Yousuf axed from teams"/><category term="agumbe"/><category term="airlines"/><category term="ata types in SQL Server 2005"/><category term="ata types or enhanced data types in SQL Server 2005"/><category term="attachment size limit of google"/><category term="bangalore theatres"/><category term="bangalore theatres address"/><category term="bangalore theatres location"/><category term="barney"/><category term="bavishya"/><category term="bhavishya"/><category term="bing"/><category term="block diagram of Satellite Transponder"/><category term="blue beer"/><category term="brings video calls to the iPhone"/><category term="call from michael jaksons home"/><category term="champions league 2009"/><category term="champions league cricket"/><category term="champions league cricket 2009"/><category term="champions league schedule"/><category term="champions league t20"/><category term="champions league t20 super 8"/><category term="champions league t20 super8 fixture"/><category term="champions league t20 super8 schedule"/><category term="cheating death"/><category term="china cell phone"/><category term="china mobile"/><category term="china phone with java"/><category term="common wealth games 2010 results"/><category term="common wealth games medal table"/><category term="common wealth games results"/><category term="common wealth games todays results"/><category term="decriminalize marijuana bill"/><category term="departure might lead to new fighting"/><category term="diamond-studded crown"/><category term="difference between Persistent and Nonpersistent Connections"/><category term="diganth photos"/><category term="education in nasa"/><category term="egg mail"/><category term="endhiran is remake of Kannada film HOLLYWOOD"/><category term="endhiran is remake of Kannada movie HOLLYWOOD"/><category term="enhanced Google Music Search"/><category term="enhanced data types in SQL Server 2005"/><category term="fishing side effects"/><category term="frank"/><category term="frequently asked C interview questions with answers"/><category term="ganapathi"/><category term="ganapathi habba"/><category term="ganesha"/><category term="ganesha chathurthi"/><category term="ganesha chaturthi"/><category term="gmail attachment size limit"/><category term="gmail attachment size limit is 25mb"/><category term="gmail attachment size limit is 25mb now"/><category term="google Interview Questions and Answers"/><category term="gprs setting for china mobile"/><category term="great escape"/><category term="h1n1 treatment"/><category term="handoff technique"/><category term="hero honda service centers"/><category term="hero honda service centers at bangalore"/><category term="hindi movie Kites review"/><category term="home interior decoration tips"/><category term="house interior decoration tips"/><category term="how open .mdi file"/><category term="how open mdi file"/><category term="how to Keep yourself safe safe from swine flu"/><category term="how to Use Google Voice with existing number"/><category term="how to Use Google Voice with old number"/><category term="how to Use Google Voice with your existing number"/><category term="how to check What&#39;s Eating Your Hard Drive Space"/><category term="how to connect sata hard disk to pc"/><category term="how to cure h1n1"/><category term="how to improve the performance of pc"/><category term="how to install sata hard disk to pc"/><category term="how to make computer fat"/><category term="iPhone 3G for 99 dollars"/><category term="iPhone OS 4 comes on 8 April"/><category term="iPhone OS 4.0 is now official with over 100 new features"/><category term="iPhone OS 4.0 overview"/><category term="iPhone SMS Bug Released Today"/><category term="iPhone SMS Bug Released Today - Leaves all iPhones Vulnerable to Attack"/><category term="iPhone for 99 dollars"/><category term="iPhone for 99$"/><category term="idea"/><category term="idea karnataka"/><category term="india vs australia ODI Series 2009 Schedule"/><category term="india vs australia ODI Series 2009 fixture"/><category term="india vs australia ODI Series Schedule"/><category term="india vs australia ODI Series fixture"/><category term="interior decoration tips"/><category term="iphone"/><category term="iphone 3g"/><category term="iphone bug"/><category term="ipl 2010"/><category term="ipl 2010 schedule"/><category term="ipl season 3"/><category term="ipl session 3 fixture"/><category term="ipl session 3 schedule"/><category term="java china mobile"/><category term="jobs in nasa"/><category term="jog"/><category term="jog falls"/><category term="josh film hero rakesh&#39;s new film"/><category term="just maat maatalli songs"/><category term="just maat maatalli songs download"/><category term="just maat maathalli audio release"/><category term="just maat maathalli songs"/><category term="just maat maathalli songs download"/><category term="just maath maathalli songs download"/><category term="kannada blogs"/><category term="kannada cinema news"/><category term="kannada film super audio release date"/><category term="kannada magazines"/><category term="kannada movie Ram review"/><category term="kannada movie super audio release date"/><category term="kannada movie super release date"/><category term="kannada portal"/><category term="kannada songs"/><category term="kannada tools"/><category term="karnataka"/><category term="karnataka premier league fixture"/><category term="karnataka premier league match fixture"/><category term="kayak"/><category term="kayak vs bing"/><category term="khanija bhavan"/><category term="kpl"/><category term="kpl fixture"/><category term="kpl match fixture"/><category term="kpl match schedule"/><category term="kpl schedule"/><category term="life bans on Mohammad Yousuf and Younis Khan"/><category term="live streaming of kpl 2010"/><category term="magic pill to live more than 100 years"/><category term="malenaadu"/><category term="mangalore airtel"/><category term="marijuana"/><category term="match fixing in Champions Trophy 2009"/><category term="matlab Programs"/><category term="medicine for h1n1"/><category term="medicine to live 100 years"/><category term="medicine to live longer"/><category term="microsoft Interview Questions and Answers"/><category term="moon 2009"/><category term="multi touch cellphones"/><category term="multi touch mobiles"/><category term="multi-touch cellphones"/><category term="music director of kannada film super"/><category term="muslim citizen has translated Bhagavad Gita to Urdu"/><category term="nasa"/><category term="new IMEI number from the government by paying a minimal cost of Rs 199"/><category term="new nokia 5530"/><category term="nidhi subbaiah photos"/><category term="nidi subbaiah wallpapers"/><category term="nokia"/><category term="nokia 5530"/><category term="nokia software"/><category term="nokia softwares"/><category term="not install on your PCs"/><category term="one women one dress one year"/><category term="online teaching by IIT"/><category term="online teaching by IIT&#39;s"/><category term="plans for Chrome cloud synchronization"/><category term="poor"/><category term="poor students"/><category term="pot"/><category term="powerless to stop war in Afghanistan"/><category term="prasanna got new mobile"/><category term="prisons"/><category term="program to find the IDFT"/><category term="pruthvi film songs download"/><category term="pruthvi movie songs download"/><category term="resistive touch screen"/><category term="resistive touchscreen"/><category term="russia got Space-Spectrometer"/><category term="satyam is renamed as Mahindra Satyam"/><category term="save our tigers just 1411 left"/><category term="shimoga"/><category term="shri Krishna Janmashtami"/><category term="six-mile high explosion in moon"/><category term="species at risk"/><category term="sri Krishna Janmashtami"/><category term="sringeri"/><category term="sslc"/><category term="stroke"/><category term="students"/><category term="super movie to start from feb 17th"/><category term="super movie update"/><category term="symptoms of H1N1"/><category term="tallest building in india"/><category term="target"/><category term="telgu film orange release date"/><category term="theatres in bangalore"/><category term="third of species at risk"/><category term="thirthahalli"/><category term="touch screen"/><category term="touchscreen"/><category term="tulsi"/><category term="udaya varthegalu live"/><category term="upendra has placed an ad calling aspirants to audition for his upcoming film"/><category term="upendra inviting applications from aspiring actors for his next film"/><category term="upendra&#39;s Super mivie wallpapers"/><category term="upendra&#39;s new film super"/><category term="upendra&#39;s super"/><category term="vacancies in nasa"/><category term="visual search by microsoft"/><category term="water found on the Moon"/><category term="water in moon"/><category term="water less washing machine"/><category term="water source found in moon"/><category term="welcome back ultrasn0w"/><category term="western ghats"/><category term="what is Maya calendar"/><category term="what is Satellite Transponder expalin with block diagram"/><category term="what to do After stroke"/><category term="who is the music director of film super"/><category term="who is the music director of super"/><category term="why we are celeberating Navrathri festival"/><category term="why we are celeberating Navratri festival"/><category term="will get disconnected within 2-3 days"/><category term="world&#39;s first mobile phone"/><category term="worldcup semifinal"/><category term="yeddelu Manjunatha"/><category term="yeddelu Manjunatha video"/><category term="yet another record by sachin"/><category term="you can send and receive messages up to 25 megabytes"/><category term="your mail on time"/><category term="ಜೋಶ್ ಖ್ಯಾತಿಯ ರಾಕೇಶನ ಹೊಸ ಚಿತ್ರ"/><title type='text'>Malenaadu</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://allaboutshimoga.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>663</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-1690567729819417850</id><published>2011-02-18T18:08:00.000+05:30</published><updated>2017-03-30T13:28:38.526+05:30</updated><title type='text'>DataStructure Program to convert an Infix expression to Prefix form.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;Section1&quot;&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: white; font-family: Times New Roman; font-size: small;&quot;&gt;&lt;span style=&quot;color: white; font-size: 12.0pt;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt; #include &amp;lt;conio.h&amp;gt;&lt;br /&gt; #include &amp;lt;string.h&amp;gt;&lt;br /&gt; #include &amp;lt;ctype.h&amp;gt;&lt;br /&gt; #define MAX 50&lt;br /&gt; struct infix&lt;br /&gt; {&lt;br /&gt; char target[MAX] ;&lt;br /&gt; char stack[MAX] ;&lt;br /&gt; char *s, *t ;&lt;br /&gt; int top, l ;&lt;br /&gt; } ;&lt;br /&gt; void initinfix ( struct infix * ) ;&lt;br /&gt; void setexpr ( struct infix *, char * ) ;&lt;br /&gt; void push ( struct infix *, char ) ;&lt;br /&gt; char &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_convert_an_Infix_expression_to_Prefix_form.html&quot; id=&quot;KonaLink0&quot; style=&quot;font-size: inherit; font-weight: inherit;&quot;&gt;&lt;span class=&quot;klink&quot;&gt;&lt;span style=&quot;color: white; font-size: inherit; font-weight: inherit;&quot;&gt;&lt;span style=&quot;font-size: inherit; font-weight: inherit;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;pop&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; ( struct infix * ) ;&lt;br /&gt; void convert ( struct infix * ) ;&lt;br /&gt; int priority ( char c ) ;&lt;br /&gt; void show ( struct infix ) ;&lt;br /&gt; void main( )&lt;br /&gt; {&lt;br /&gt; struct infix q ;&lt;br /&gt; char expr[MAX] ;&lt;br /&gt; clrscr( ) ;&lt;br /&gt; initinfix ( &amp;amp;q ) ;&lt;br /&gt; printf ( &quot;\nEnter an expression in infix form: &quot; ) ;&lt;br /&gt; gets ( expr ) ;&lt;br /&gt; setexpr ( &amp;amp;q, expr ) ;&lt;br /&gt; convert ( &amp;amp;q ) ;&lt;br /&gt; printf ( &quot;The Prefix expression is: &quot; ) ;&lt;br /&gt; show ( q ) ;&lt;br /&gt; getch( ) ;&lt;br /&gt; }&lt;br /&gt; /* initializes elements of structure variable */&lt;br /&gt; void initinfix ( struct infix *pq )&lt;br /&gt; {&lt;br /&gt; pq -&amp;gt; top = -1 ;&lt;br /&gt; strcpy ( pq -&amp;gt; target, &quot;&quot; ) ;&lt;br /&gt; strcpy ( pq -&amp;gt; stack, &quot;&quot; ) ;&lt;br /&gt; pq -&amp;gt; l = 0 ;&lt;br /&gt; }&lt;br /&gt; /* reverses the given expression */&lt;br /&gt; void setexpr ( struct infix *pq, char *str )&lt;br /&gt; {&lt;br /&gt; pq -&amp;gt; s = str ;&lt;br /&gt; strrev ( pq -&amp;gt; s ) ;&lt;br /&gt; pq -&amp;gt; l = strlen ( pq -&amp;gt; s ) ;&lt;br /&gt; *( pq -&amp;gt; target + pq -&amp;gt; l ) = &#39;\0&#39; ;&lt;br /&gt; pq -&amp;gt; t = pq -&amp;gt; target + ( pq -&amp;gt; l - 1 ) ;&lt;br /&gt; }&lt;br /&gt; /* adds operator to the stack */&lt;br /&gt; void push ( struct infix *pq, char c )&lt;br /&gt; {&lt;br /&gt; if ( pq -&amp;gt; top == MAX - 1 )&lt;br /&gt; printf ( &quot;\nStack is full.\n&quot; ) ;&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; pq -&amp;gt; top++ ;&lt;br /&gt; pq -&amp;gt; stack[pq -&amp;gt; top] = c ;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; /* pops an operator from the stack */&lt;br /&gt; char pop ( struct infix *pq )&lt;br /&gt; {&lt;br /&gt; if ( pq -&amp;gt; top == -1 )&lt;br /&gt; {&lt;br /&gt; printf ( &quot;Stack is empty\n&quot; ) ;&lt;br /&gt; return -1 ;&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; char item = pq -&amp;gt; stack[pq -&amp;gt; top] ;&lt;br /&gt; pq -&amp;gt; top-- ;&lt;br /&gt; return item ;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; /* converts the infix expr. to prefix form */&lt;br /&gt; void convert ( struct infix *pq )&lt;br /&gt; {&lt;br /&gt; char opr ;&lt;br /&gt; while ( *( pq -&amp;gt; s ) )&lt;br /&gt; {&lt;br /&gt; if ( *( pq -&amp;gt; s ) == &#39; &#39; || *( pq -&amp;gt; s ) == &#39;\t&#39; )&lt;br /&gt; {&lt;br /&gt; pq -&amp;gt; s++ ;&lt;br /&gt; continue ;&lt;br /&gt; }&lt;br /&gt; if ( isdigit ( *( pq -&amp;gt; s ) ) || isalpha ( *( pq -&amp;gt; s ) ) )&lt;br /&gt; {&lt;br /&gt; while ( isdigit ( *( pq -&amp;gt; s ) ) || isalpha ( *( pq -&amp;gt; s ) ) )&lt;br /&gt; {&lt;br /&gt; *( pq -&amp;gt; t ) = *( pq -&amp;gt; s ) ;&lt;br /&gt; pq -&amp;gt; s++ ;&lt;br /&gt; pq -&amp;gt; t-- ;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; if ( *( pq -&amp;gt; s ) == &#39;)&#39; )&lt;br /&gt; {&lt;br /&gt; push ( pq, *( pq -&amp;gt; s ) ) ;&lt;br /&gt; pq -&amp;gt; s++ ;&lt;br /&gt; }&lt;br /&gt; if ( *( pq -&amp;gt; s ) == &#39;*&#39; || *( pq -&amp;gt; s ) == &#39;+&#39; || *( pq -&amp;gt; s ) == &#39;/&#39; || *( pq -&amp;gt; s ) == &#39;%&#39; || *( pq -&amp;gt; s ) == &#39;-&#39; || *( pq -&amp;gt; s ) == &#39;$&#39; )&lt;br /&gt; {&lt;br /&gt; if ( pq -&amp;gt; top != -1 )&lt;br /&gt; {&lt;br /&gt; opr = pop ( pq ) ;&lt;br /&gt; while ( priority ( opr ) &amp;gt; priority ( *( pq -&amp;gt; s ) ) )&lt;br /&gt; {&lt;br /&gt; *( pq -&amp;gt; t ) = opr ;&lt;br /&gt; pq -&amp;gt; t-- ;&lt;br /&gt; opr = pop ( pq ) ;&lt;br /&gt; }&lt;br /&gt; push ( pq, opr ) ;&lt;br /&gt; push ( pq, *( pq -&amp;gt; s ) ) ;&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; push ( pq, *( pq -&amp;gt; s ) ) ;&lt;br /&gt; pq -&amp;gt; s++ ;&lt;br /&gt; }&lt;br /&gt; if ( *( pq -&amp;gt; s ) == &#39;(&#39; )&lt;br /&gt; {&lt;br /&gt; opr = pop ( pq ) ;&lt;br /&gt; while ( opr != &#39;)&#39; )&lt;br /&gt; {&lt;br /&gt; *( pq -&amp;gt; t ) = opr ;&lt;br /&gt; pq -&amp;gt; t-- ;&lt;br /&gt; opr = pop ( pq ) ;&lt;br /&gt; }&lt;br /&gt; pq -&amp;gt; s++ ;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; while ( pq -&amp;gt; top != -1 )&lt;br /&gt; {&lt;br /&gt; opr = pop ( pq ) ;&lt;br /&gt; *( pq -&amp;gt; t ) = opr ;&lt;br /&gt; pq -&amp;gt; t-- ;&lt;br /&gt; }&lt;br /&gt; pq -&amp;gt; t++ ;&lt;br /&gt; }&lt;br /&gt; /* returns the priotity of the operator */&lt;br /&gt; int priority ( char c )&lt;br /&gt; {&lt;br /&gt; if ( c == &#39;$&#39; )&lt;br /&gt; return 3 ;&lt;br /&gt; if ( c == &#39;*&#39; || c == &#39;/&#39; || c == &#39;%&#39; )&lt;br /&gt; return 2 ;&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; if ( c == &#39;+&#39; || c == &#39;-&#39; )&lt;br /&gt; return 1 ;&lt;br /&gt; else&lt;br /&gt; return 0 ;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; /* displays the prefix form of given expr. */&lt;br /&gt; void show ( struct infix pq )&lt;br /&gt; {&lt;br /&gt; while ( *( pq.t ) )&lt;br /&gt; {&lt;br /&gt; printf ( &quot; %c&quot;, *( pq.t ) ) ;&lt;br /&gt; pq.t++ ;&lt;br /&gt; }&lt;br /&gt; }&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: white; font-family: Arial; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: white; font-family: &amp;quot;arial&amp;quot;; font-size: 10.0pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/1690567729819417850'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/1690567729819417850'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-convert-infix.html' title='DataStructure Program to convert an Infix expression to Prefix form.'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-5134440279033239206</id><published>2011-02-18T12:55:00.001+05:30</published><updated>2011-02-18T13:01:41.356+05:30</updated><title type='text'>DataStructure Program to merge two 1-D arrays</title><content type='html'>&lt;div class=Section1&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;&lt;br&gt; #include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; &lt;br&gt; #include &amp;lt;alloc.h&amp;gt;&lt;br&gt; #define MAX1 5&lt;br&gt; #define MAX2 7&lt;br&gt; int *arr ;&lt;br&gt; int* create ( int ) ;&lt;br&gt; void sort ( int *, int ) ;&lt;br&gt; void display ( int *, int ) ;&lt;br&gt; int* merge ( int *, int * ) ;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; int *a, *b, *c ;&lt;br&gt; clrscr( ) ;&lt;br&gt; printf ( &amp;quot;\nEnter elements for first array: \n\n&amp;quot; ) ;&lt;br&gt; a = create ( MAX1 ) ;&lt;br&gt; printf ( &amp;quot;\nEnter elements for second array: \n\n&amp;quot; ) ;&lt;br&gt; b = create ( MAX2 ) ;&lt;br&gt; sort ( a, MAX1 ) ;&lt;br&gt; sort ( b, MAX2 ) ;&lt;br&gt; printf ( &amp;quot;\nFirst array: \n&amp;quot; ) ;&lt;br&gt; display ( a, MAX1 ) ;&lt;br&gt; printf ( &amp;quot;\n\nSecond array: \n&amp;quot; ) ;&lt;br&gt; display ( b, MAX2 ) ;&lt;br&gt; printf ( &amp;quot;\n\nAfter Merging: \n&amp;quot; ) ;&lt;br&gt; c = merge ( a, b ) ;&lt;br&gt; display ( c, MAX1 + MAX2 ) ;&lt;br&gt; getch( ) ;&lt;br&gt; }&lt;br&gt; /* creates array of given size, dynamically */&lt;br&gt; int* create ( int size )&lt;br&gt; {&lt;br&gt; int *arr, i ;&lt;br&gt; arr = ( int * ) malloc ( sizeof ( int ) * size ) ;&lt;br&gt; for ( i = 0 ; i &amp;lt; size ; i++ )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;Enter the element no. %d: &amp;quot;, i + 1 ) ;&lt;br&gt; scanf ( &amp;quot;%d&amp;quot;, &amp;amp;arr[i] ) ;&lt;br&gt; }&lt;br&gt; return arr ;&lt;br&gt; } &lt;br&gt; /* sorts array in ascending order */&lt;br&gt; void sort ( int *arr, int size )&lt;br&gt; {&lt;br&gt; int i, temp, j ;&lt;br&gt; for ( i = 0 ; i &amp;lt; size ; i++ )&lt;br&gt; {&lt;br&gt; for ( j = i + 1 ; j &amp;lt; size ; j++ )&lt;br&gt; {&lt;br&gt; if ( arr[i] &amp;gt; arr[j] )&lt;br&gt; {&lt;br&gt; temp = arr[i] ;&lt;br&gt; arr[i] = arr[j] ;&lt;br&gt; arr[j] = temp ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* displays the contents of array */&lt;br&gt; void display ( int *arr, int size )&lt;br&gt; {&lt;br&gt; int i ;&lt;br&gt; for ( i = 0 ; i &amp;lt; size ; i++)&lt;br&gt; printf ( &amp;quot;%d\t&amp;quot;, arr[i] ) ;&lt;br&gt; }&lt;br&gt; /* merges two arrays of different size */&lt;br&gt; int* merge ( int *a, int *b )&lt;br&gt; {&lt;br&gt; int *arr ;&lt;br&gt; int i, k, j ;&lt;br&gt; int size = MAX1 + MAX2 ;&lt;br&gt; arr = ( int * ) malloc ( sizeof ( int ) * ( size ) ) ;&lt;br&gt; for ( k = 0, j = 0, i = 0 ; i &amp;lt;= size ; i++ )&lt;br&gt; {&lt;br&gt; if ( a[k] &amp;lt; b[j] )&lt;br&gt; {&lt;br&gt; arr[i] = a[k] ;&lt;br&gt; k++ ;&lt;br&gt; if ( k &amp;gt;= MAX1 )&lt;br&gt; {&lt;br&gt; for ( i++ ; j &amp;lt; MAX2 ; j++, i++ )&lt;br&gt; arr[i] = b[j] ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; arr[i] = b[j] ;&lt;br&gt; j++ ;&lt;br&gt; if ( j &amp;gt;= MAX2 )&lt;br&gt; {&lt;br&gt; for ( i++ ; k &amp;lt; MAX1 ; k++, i++ )&lt;br&gt; arr[i] = a[k] ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; }&lt;br&gt; return arr ;&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/5134440279033239206'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/5134440279033239206'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-merge-two-1-d.html' title='DataStructure Program to merge two 1-D arrays'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-3645768266870108262</id><published>2011-02-18T12:55:00.000+05:30</published><updated>2011-02-18T13:00:16.688+05:30</updated><title type='text'>DataStructure-Program to merge two linked list</title><content type='html'>&lt;div class=Section1&gt;  &lt;h2&gt;&lt;b&gt;&lt;font size=5 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size: 18.0pt;color:white&#39;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/b&gt;&lt;/h2&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; #include &amp;lt;alloc.h&amp;gt;&lt;br&gt; /* structure containing a &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_merge_two_linked_list.html&quot; id=KonaLink1 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;data&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; part and link part */&lt;br&gt; struct node&lt;br&gt; {&lt;br&gt; &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_merge_two_linked_list.html&quot; id=KonaLink2 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;int&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; data ;&lt;br&gt; struct node *link ;&lt;br&gt; } ;&lt;br&gt; void add ( struct node **, int ) ;&lt;br&gt; void display ( struct node * ) ;&lt;br&gt; int count ( struct node * ) ;&lt;br&gt; void merge ( struct node *, struct node *, struct node ** ) ;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; struct node *first, *second, *third ;&lt;br&gt; first = second = third = &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_merge_two_linked_list.html&quot; id=KonaLink3 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; ; /* empty linked lists */&lt;br&gt; add ( &amp;amp;first, 9 ) ;&lt;br&gt; add ( &amp;amp;first, 12 ) ;&lt;br&gt; add ( &amp;amp;first, 14 ) ;&lt;br&gt; add ( &amp;amp;first, 17 ) ;&lt;br&gt; add ( &amp;amp;first, 35 ) ;&lt;br&gt; add ( &amp;amp;first, 61 ) ;&lt;br&gt; add ( &amp;amp;first, 79 ) ;&lt;br&gt; clrscr( ) ;&lt;br&gt; printf ( &amp;quot;First linked list : &amp;quot; ) ;&lt;br&gt; display ( first ) ;&lt;br&gt; printf ( &amp;quot;\nNo. of elements in Linked List : %d&amp;quot; , count ( first ) ) ;&lt;br&gt; add ( &amp;amp;second, 12 ) ;&lt;br&gt; add ( &amp;amp;second, 17 ) ;&lt;br&gt; add ( &amp;amp;second, 24 ) ;&lt;br&gt; add ( &amp;amp;second, 36 ) ;&lt;br&gt; add ( &amp;amp;second, 59 ) ;&lt;br&gt; add ( &amp;amp;second, 64 ) ;&lt;br&gt; add ( &amp;amp;second, 87 ) ;&lt;br&gt; printf ( &amp;quot;\n\nSecond linked list : &amp;quot; ) ;&lt;br&gt; display ( second ) ;&lt;br&gt; printf ( &amp;quot;\nNo. of elements in Linked List : %d&amp;quot; , count ( second ) ) ;&lt;br&gt; merge ( first, second, &amp;amp;third ) ;&lt;br&gt; printf ( &amp;quot;\n\nThe merged list : &amp;quot; ) ;&lt;br&gt; display ( third ) ;&lt;br&gt; printf ( &amp;quot;\nNo. of elements in Linked List : %d&amp;quot;, count ( third ) ) ;&lt;br&gt; }&lt;br&gt; /* adds node to an ascending order linked list */&lt;br&gt; void add ( struct node **q, int num )&lt;br&gt; {&lt;br&gt; struct node *r, *temp = *q ;&lt;br&gt; r = malloc ( sizeof ( struct node ) ) ;&lt;br&gt; r -&amp;gt; data = num ;&lt;br&gt; /* if list is empty or if new node is to be inserted before the first node */&lt;br&gt; if ( *q == NULL || ( *q ) -&amp;gt; data &amp;gt; num )&lt;br&gt; {&lt;br&gt; *q = r ;&lt;br&gt; ( *q ) -&amp;gt; link = temp ;&lt;br&gt; }&lt;br&gt; &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_merge_two_linked_list.html&quot; id=KonaLink4 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;br&gt; {&lt;br&gt; /* traverse the entire linked list to search the position to insert the new node */&lt;br&gt; while ( temp != NULL )&lt;br&gt; {&lt;br&gt; if ( temp -&amp;gt; data &amp;lt; num &amp;amp;&amp;amp; ( temp -&amp;gt; link -&amp;gt; data &amp;gt; num || temp -&amp;gt; link == NULL ))&lt;br&gt; {&lt;br&gt; r -&amp;gt; link = temp -&amp;gt; link ;&lt;br&gt; temp -&amp;gt; link = r ;&lt;br&gt; return ;&lt;br&gt; }&lt;br&gt; temp = temp -&amp;gt; link ; /*go to next node */&lt;br&gt; }&lt;br&gt; r -&amp;gt; link = NULL ;&lt;br&gt; temp -&amp;gt; link = r ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_merge_two_linked_list.html&quot; id=KonaLink5 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;displays&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; the contents of the linked list */&lt;br&gt; void display ( struct node *q )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;\n&amp;quot; ) ;&lt;br&gt; /* traverse the entire linked list */&lt;br&gt; while ( q != NULL )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;%d &amp;quot;, q -&amp;gt; data ) ;&lt;br&gt; q = q -&amp;gt; link ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_merge_two_linked_list.html&quot; id=KonaLink6 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;counts&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; the number of nodes present in the linked list */&lt;br&gt; int count ( struct node * q )&lt;br&gt; {&lt;br&gt; int c = 0 ;&lt;br&gt; /* traverse the entire linked list */&lt;br&gt; while ( q != NULL )&lt;br&gt; {&lt;br&gt; q = q -&amp;gt; link ;&lt;br&gt; c++ ;&lt;br&gt; }&lt;br&gt; return c ;&lt;br&gt; }&lt;br&gt; /* merges the two linked lists, restricting the common elements to occur only once in the final list */&lt;br&gt; void merge ( struct node *p, struct node *q, struct node **s )&lt;br&gt; {&lt;br&gt; struct node *z ;&lt;br&gt; z = NULL ;&lt;br&gt; /* if both lists are empty */&lt;br&gt; if ( p == NULL &amp;amp;&amp;amp; q == NULL )&lt;br&gt; return ;&lt;br&gt; /* traverse both linked lists till the end. If end of any one list is reached &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_merge_two_linked_list.html&quot; id=KonaLink7 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;loop&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; is terminated */&lt;br&gt; while ( p != NULL &amp;amp;&amp;amp; q != NULL )&lt;br&gt; {&lt;br&gt; /* if node being added in the first node */&lt;br&gt; if ( *s == NULL )&lt;br&gt; { *s = malloc ( sizeof ( struct node ) ) ;&lt;br&gt; z = *s ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; z -&amp;gt; link = malloc ( sizeof ( struct node ) ) ;&lt;br&gt; z = z -&amp;gt; link ;&lt;br&gt; }&lt;br&gt; if ( p -&amp;gt; data &amp;lt; q -&amp;gt; data )&lt;br&gt; {&lt;br&gt; z -&amp;gt; data = p -&amp;gt; data ;&lt;br&gt; p = p -&amp;gt; link ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; if ( q -&amp;gt; data &amp;lt; p -&amp;gt; data )&lt;br&gt; {&lt;br&gt; z -&amp;gt; data = q -&amp;gt; data ;&lt;br&gt; q = q -&amp;gt; link ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; if ( p -&amp;gt; data == q -&amp;gt; data )&lt;br&gt; {&lt;br&gt; z -&amp;gt; data = q -&amp;gt; data ;&lt;br&gt; p = p -&amp;gt; link ;&lt;br&gt; q = q -&amp;gt; link ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* if end of first list has not been reached */&lt;br&gt; while ( p != NULL )&lt;br&gt; {&lt;br&gt; z -&amp;gt; link = malloc ( sizeof ( struct node ) ) ;&lt;br&gt; z = z -&amp;gt; link ;&lt;br&gt; z -&amp;gt; data = p -&amp;gt; data ;&lt;br&gt; p = p -&amp;gt; link ;&lt;br&gt; }&lt;br&gt; /* if end of second list has been reached */&lt;br&gt; while ( q != NULL )&lt;br&gt; {&lt;br&gt; z -&amp;gt; link = malloc ( sizeof ( struct node ) ) ;&lt;br&gt; z = z -&amp;gt; link ;&lt;br&gt; z -&amp;gt; data = q -&amp;gt; data ;&lt;br&gt; q = q -&amp;gt; link ;&lt;br&gt; }&lt;br&gt; z -&amp;gt; link = NULL ;&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/3645768266870108262'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/3645768266870108262'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-merge-two.html' title='DataStructure-Program to merge two linked list'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-5364619848247355318</id><published>2011-02-18T12:54:00.001+05:30</published><updated>2011-02-18T13:01:58.368+05:30</updated><title type='text'>DataStructure Program to maintain an AVL tree</title><content type='html'>&lt;div class=Section1&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; #include &amp;lt;alloc.h&amp;gt;&lt;br&gt; #define FALSE 0&lt;br&gt; #define TRUE 1&lt;br&gt; struct AVLNode&lt;br&gt; {&lt;br&gt; int data ;&lt;br&gt; int balfact ;&lt;br&gt; struct AVLNode *left ;&lt;br&gt; struct AVLNode *right ;&lt;br&gt; } ;&lt;br&gt; struct AVLNode * buildtree ( struct AVLNode *, int, int * ) ;&lt;br&gt; struct AVLNode * deldata ( struct AVLNode *, int, int * ) ;&lt;br&gt; struct AVLNode * &lt;st1:place w:st=&quot;on&quot;&gt;&lt;st1:State w:st=&quot;on&quot;&gt;del&lt;/st1:State&gt;&lt;/st1:place&gt; ( struct AVLNode *, struct AVLNode *, int * ) ;&lt;br&gt; struct AVLNode * balright ( struct AVLNode *, int * ) ;&lt;br&gt; struct AVLNode * balleft ( struct AVLNode *, int * ) ;&lt;br&gt; void display ( struct AVLNode * ) ;&lt;br&gt; void deltree ( struct AVLNode * ) ;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; struct AVLNode *avl = NULL ;&lt;br&gt; int h ;&lt;br&gt; clrscr( ) ;&lt;br&gt; avl = buildtree ( avl, 20, &amp;amp;h ) ;&lt;br&gt; avl = buildtree ( avl, 6, &amp;amp;h ) ;&lt;br&gt; avl = buildtree ( avl, 29, &amp;amp;h ) ;&lt;br&gt; avl = buildtree ( avl, 5, &amp;amp;h ) ;&lt;br&gt; avl = buildtree ( avl, 12, &amp;amp;h ) ;&lt;br&gt; avl = buildtree ( avl, 25, &amp;amp;h ) ;&lt;br&gt; avl = buildtree ( avl, 32, &amp;amp;h ) ;&lt;br&gt; avl = buildtree ( avl, 10, &amp;amp;h ) ;&lt;br&gt; avl = buildtree ( avl, 15, &amp;amp;h ) ;&lt;br&gt; avl = buildtree ( avl, 27, &amp;amp;h ) ;&lt;br&gt; avl = buildtree ( avl, 13, &amp;amp;h ) ;&lt;br&gt; printf ( &amp;quot;\nAVL tree:\n&amp;quot; ) ;&lt;br&gt; display ( avl ) ;&lt;br&gt; avl = deldata ( avl, 20, &amp;amp;h ) ;&lt;br&gt; avl = deldata ( avl, 12, &amp;amp;h ) ;&lt;br&gt; printf ( &amp;quot;\nAVL tree after deletion of a node:\n&amp;quot; ) ;&lt;br&gt; display ( avl ) ;&lt;br&gt; deltree ( avl ) ;&lt;br&gt; getch( ) ;&lt;br&gt; }&lt;br&gt; /* inserts an element into tree */&lt;br&gt; struct AVLNode * buildtree ( struct AVLNode *root, int data, int *h )&lt;br&gt; {&lt;br&gt; struct AVLNode *node1, *node2 ;&lt;br&gt; if ( !root )&lt;br&gt; {&lt;br&gt; root = ( struct AVLNode * ) malloc ( sizeof ( struct AVLNode ) ) ;&lt;br&gt; root -&amp;gt; data = data ;&lt;br&gt; root -&amp;gt; left = NULL ;&lt;br&gt; root -&amp;gt; right = NULL ;&lt;br&gt; root -&amp;gt; balfact = 0 ;&lt;br&gt; *h = TRUE ;&lt;br&gt; return ( root ) ;&lt;br&gt; }&lt;br&gt; if ( data &amp;lt; root -&amp;gt; data )&lt;br&gt; {&lt;br&gt; root -&amp;gt; left = buildtree ( root -&amp;gt; left, data, h ) ;&lt;br&gt; /* If left subtree is higher */&lt;br&gt; if ( *h )&lt;br&gt; {&lt;br&gt; switch ( root -&amp;gt; balfact )&lt;br&gt; {&lt;br&gt; case 1:&lt;br&gt; node1 = root -&amp;gt; left ;&lt;br&gt; if ( node1 -&amp;gt; balfact == 1 )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;\nRight rotation along %d.&amp;quot;, root -&amp;gt; data ) ;&lt;br&gt; root -&amp;gt; left = node1 -&amp;gt; right ;&lt;br&gt; node1 -&amp;gt; right = root ;&lt;br&gt; root -&amp;gt; balfact = 0 ;&lt;br&gt; root = node1 ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;\nDouble rotation, left along %d&amp;quot;, node1 -&amp;gt; data ) ;&lt;br&gt; node2 = node1 -&amp;gt; right ;&lt;br&gt; node1 -&amp;gt; right = node2 -&amp;gt; left ;&lt;br&gt; printf ( &amp;quot; then right along %d.\n&amp;quot;, root -&amp;gt; data ) ;&lt;br&gt; node2 -&amp;gt; left = node1 ;&lt;br&gt; root -&amp;gt; left = node2 -&amp;gt; right ;&lt;br&gt; node2 -&amp;gt; right = root ;&lt;br&gt; if ( node2 -&amp;gt; balfact == 1 )&lt;br&gt; root -&amp;gt; balfact = -1 ;&lt;br&gt; else&lt;br&gt; root -&amp;gt; balfact = 0 ;&lt;br&gt; if ( node2 -&amp;gt; balfact == -1 )&lt;br&gt; node1 -&amp;gt; balfact = 1 ;&lt;br&gt; else&lt;br&gt; node1 -&amp;gt; balfact = 0 ;&lt;br&gt; root = node2 ;&lt;br&gt; }&lt;br&gt; root -&amp;gt; balfact = 0 ;&lt;br&gt; *h = FALSE ;&lt;br&gt; break ;&lt;br&gt; case 0:&lt;br&gt; root -&amp;gt; balfact = 1 ;&lt;br&gt; break ;&lt;br&gt; case -1:&lt;br&gt; root -&amp;gt; balfact = 0 ;&lt;br&gt; *h = FALSE ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; }&lt;br&gt; if ( data &amp;gt; root -&amp;gt; data )&lt;br&gt; {&lt;br&gt; root -&amp;gt; right = buildtree ( root -&amp;gt; right, data, h ) ;&lt;br&gt; /* If the right subtree is higher */&lt;br&gt; if ( *h )&lt;br&gt; {&lt;br&gt; switch ( root -&amp;gt; balfact )&lt;br&gt; {&lt;br&gt; case 1:&lt;br&gt; root -&amp;gt; balfact = 0 ;&lt;br&gt; *h = FALSE ;&lt;br&gt; break ;&lt;br&gt; case 0:&lt;br&gt; root -&amp;gt; balfact = -1 ;&lt;br&gt; break;&lt;br&gt; case -1:&lt;br&gt; node1 = root -&amp;gt; right ;&lt;br&gt; if ( node1 -&amp;gt; balfact == -1 )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;\nLeft rotation along %d.&amp;quot;, root -&amp;gt; data ) ;&lt;br&gt; root -&amp;gt; right = node1 -&amp;gt; left ;&lt;br&gt; node1 -&amp;gt; left = root ;&lt;br&gt; root -&amp;gt; balfact = 0 ;&lt;br&gt; root = node1 ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;\nDouble rotation, right along %d&amp;quot;, node1 -&amp;gt; data ) ;&lt;br&gt; node2 = node1 -&amp;gt; left ;&lt;br&gt; node1 -&amp;gt; left = node2 -&amp;gt; right ;&lt;br&gt; node2 -&amp;gt; right = node1 ;&lt;br&gt; printf ( &amp;quot; then left along %d.\n&amp;quot;, root -&amp;gt; data ) ;&lt;br&gt; root -&amp;gt; right = node2 -&amp;gt; left ;&lt;br&gt; node2 -&amp;gt; left = root ;&lt;br&gt; if ( node2 -&amp;gt; balfact == -1 )&lt;br&gt; root -&amp;gt; balfact = 1 ;&lt;br&gt; else&lt;br&gt; root -&amp;gt; balfact = 0 ;&lt;br&gt; if ( node2 -&amp;gt; balfact == 1 )&lt;br&gt; node1 -&amp;gt; balfact = -1 ;&lt;br&gt; else&lt;br&gt; node1 -&amp;gt; balfact = 0 ;&lt;br&gt; root = node2 ;&lt;br&gt; }&lt;br&gt; root -&amp;gt; balfact = 0 ;&lt;br&gt; *h = FALSE ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; }&lt;br&gt; return ( root ) ;&lt;br&gt; }&lt;br&gt; /* deletes an item from the tree */&lt;br&gt; struct AVLNode * deldata ( struct AVLNode *root, int data, int *h )&lt;br&gt; {&lt;br&gt; struct AVLNode *node ;&lt;br&gt; if ( !root )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;\nNo such data.&amp;quot; ) ;&lt;br&gt; return ( root ) ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; if ( data &amp;lt; root -&amp;gt; data )&lt;br&gt; {&lt;br&gt; root -&amp;gt; left = deldata ( root -&amp;gt; left, data, h ) ;&lt;br&gt; if ( *h )&lt;br&gt; root = balright ( root, h ) ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; if ( data &amp;gt; root -&amp;gt; data )&lt;br&gt; {&lt;br&gt; root -&amp;gt; right = deldata ( root -&amp;gt; right, data, h ) ;&lt;br&gt; if ( *h )&lt;br&gt; root = balleft ( root, h ) ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; node = root ;&lt;br&gt; if ( node -&amp;gt; right == NULL )&lt;br&gt; {&lt;br&gt; root = node -&amp;gt; left ;&lt;br&gt; *h = TRUE ;&lt;br&gt; free ( node ) ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; { &lt;br&gt; if ( node -&amp;gt; left == NULL )&lt;br&gt; {&lt;br&gt; root = node -&amp;gt; right ;&lt;br&gt; *h = TRUE ;&lt;br&gt; free ( node ) ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; node -&amp;gt; right = &lt;st1:State w:st=&quot;on&quot;&gt;&lt;st1:place w:st=&quot;on&quot;&gt;del&lt;/st1:place&gt;&lt;/st1:State&gt; ( node -&amp;gt; right, node, h ) ;&lt;br&gt; if ( *h )&lt;br&gt; root = balleft ( root, h ) ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; }&lt;br&gt; }&lt;br&gt; }&lt;br&gt; return ( root ) ;&lt;br&gt; }&lt;br&gt; struct AVLNode * &lt;st1:State w:st=&quot;on&quot;&gt;&lt;st1:place w:st=&quot;on&quot;&gt;del&lt;/st1:place&gt;&lt;/st1:State&gt; ( struct AVLNode *succ, struct AVLNode *node, int *h )&lt;br&gt; {&lt;br&gt; struct AVLNode *temp = succ ;&lt;br&gt; if ( succ -&amp;gt; left != NULL )&lt;br&gt; {&lt;br&gt; succ -&amp;gt; left = &lt;st1:State w:st=&quot;on&quot;&gt;&lt;st1:place w:st=&quot;on&quot;&gt;del&lt;/st1:place&gt;&lt;/st1:State&gt; ( succ -&amp;gt; left, node, h ) ;&lt;br&gt; if ( *h )&lt;br&gt; succ = balright ( succ, h ) ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; temp = succ ;&lt;br&gt; node -&amp;gt; data = succ -&amp;gt; data ;&lt;br&gt; succ = succ -&amp;gt; right ;&lt;br&gt; free ( temp ) ;&lt;br&gt; *h = TRUE ;&lt;br&gt; }&lt;br&gt; return ( succ ) ;&lt;br&gt; }&lt;br&gt; /* balances the tree, if right sub-tree is higher */&lt;br&gt; struct AVLNode * balright ( struct AVLNode *root, int *h )&lt;br&gt; {&lt;br&gt; struct AVLNode *node1, *node2 ;&lt;br&gt; switch ( root -&amp;gt; balfact )&lt;br&gt; {&lt;br&gt; case 1:&lt;br&gt; root -&amp;gt; balfact = 0 ;&lt;br&gt; break;&lt;br&gt; case 0:&lt;br&gt; root -&amp;gt; balfact = -1 ;&lt;br&gt; *h = FALSE ;&lt;br&gt; break;&lt;br&gt; case -1:&lt;br&gt; node1 = root -&amp;gt; right ;&lt;br&gt; if ( node1 -&amp;gt; balfact &amp;lt;= 0 )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;\nLeft rotation along %d.&amp;quot;, root -&amp;gt; data ) ;&lt;br&gt; root -&amp;gt; right = node1 -&amp;gt; left ;&lt;br&gt; node1 -&amp;gt; left = root ;&lt;br&gt; if ( node1 -&amp;gt; balfact == 0 )&lt;br&gt; {&lt;br&gt; root -&amp;gt; balfact = -1 ;&lt;br&gt; node1 -&amp;gt; balfact = 1 ;&lt;br&gt; *h = FALSE ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; root -&amp;gt; balfact = node1 -&amp;gt; balfact = 0 ;&lt;br&gt; }&lt;br&gt; root = node1 ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;\nDouble rotation, right along %d&amp;quot;, node1 -&amp;gt; data );&lt;br&gt; node2 = node1 -&amp;gt; left ;&lt;br&gt; node1 -&amp;gt; left = node2 -&amp;gt; right ;&lt;br&gt; node2 -&amp;gt; right = node1 ;&lt;br&gt; printf ( &amp;quot; then left along %d.\n&amp;quot;, root -&amp;gt; data );&lt;br&gt; root -&amp;gt; right = node2 -&amp;gt; left ;&lt;br&gt; node2 -&amp;gt; left = root ;&lt;br&gt; if ( node2 -&amp;gt; balfact == -1 )&lt;br&gt; root -&amp;gt; balfact = 1 ;&lt;br&gt; else&lt;br&gt; root -&amp;gt; balfact = 0 ;&lt;br&gt; if ( node2 -&amp;gt; balfact == 1 )&lt;br&gt; node1 -&amp;gt; balfact = -1 ;&lt;br&gt; else&lt;br&gt; node1 -&amp;gt; balfact = 0 ;&lt;br&gt; root = node2 ;&lt;br&gt; node2 -&amp;gt; balfact = 0 ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; return ( root ) ;&lt;br&gt; }&lt;br&gt; /* balances the tree, if left sub-tree is higher */&lt;br&gt; struct AVLNode * balleft ( struct AVLNode *root, int *h )&lt;br&gt; {&lt;br&gt; struct AVLNode *node1, *node2 ;&lt;br&gt; switch ( root -&amp;gt; balfact )&lt;br&gt; {&lt;br&gt; case -1:&lt;br&gt; root -&amp;gt; balfact = 0 ;&lt;br&gt; break ;&lt;br&gt; case 0:&lt;br&gt; root -&amp;gt; balfact = 1 ;&lt;br&gt; *h = FALSE ;&lt;br&gt; break ;&lt;br&gt; case 1:&lt;br&gt; node1 = root -&amp;gt; left ;&lt;br&gt; if ( node1 -&amp;gt; balfact &amp;gt;= 0 )&lt;br&gt; { printf ( &amp;quot;\nRight rotation along %d.&amp;quot;, root -&amp;gt; data ) ;&lt;br&gt; root -&amp;gt; left = node1 -&amp;gt; right ;&lt;br&gt; node1 -&amp;gt; right = root ;&lt;br&gt; if ( node1 -&amp;gt; balfact == 0 )&lt;br&gt; {&lt;br&gt; root -&amp;gt; balfact = 1 ;&lt;br&gt; node1 -&amp;gt; balfact = -1 ;&lt;br&gt; *h = FALSE ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; root -&amp;gt; balfact = node1 -&amp;gt; balfact = 0 ;&lt;br&gt; }&lt;br&gt; root = node1 ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;\nDouble rotation, left along %d&amp;quot;, node1 -&amp;gt; data ) ;&lt;br&gt; node2 = node1 -&amp;gt; right ;&lt;br&gt; node1 -&amp;gt; right = node2 -&amp;gt; left ;&lt;br&gt; node2 -&amp;gt; left = node1 ;&lt;br&gt; printf ( &amp;quot; then right along %d.\n&amp;quot;, root -&amp;gt; data ) ;&lt;br&gt; root -&amp;gt; left = node2 -&amp;gt; right ;&lt;br&gt; node2 -&amp;gt; right = root ;&lt;br&gt; if ( node2 -&amp;gt; balfact == 1 )&lt;br&gt; root -&amp;gt; balfact = -1 ;&lt;br&gt; else&lt;br&gt; root -&amp;gt; balfact = 0 ;&lt;br&gt; if ( node2-&amp;gt; balfact == -1 )&lt;br&gt; node1 -&amp;gt; balfact = 1 ;&lt;br&gt; else&lt;br&gt; node1 -&amp;gt; balfact = 0 ;&lt;br&gt; root = node2 ;&lt;br&gt; node2 -&amp;gt; balfact = 0 ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; return ( root ) ;&lt;br&gt; }&lt;br&gt; /* displays the tree in-order */&lt;br&gt; void display ( struct AVLNode *root )&lt;br&gt; {&lt;br&gt; if ( root != NULL )&lt;br&gt; {&lt;br&gt; display ( root -&amp;gt; left ) ;&lt;br&gt; printf ( &amp;quot;%d\t&amp;quot;, root -&amp;gt; data ) ;&lt;br&gt; display ( root -&amp;gt; right ) ;&lt;br&gt; }&lt;br&gt; } &lt;br&gt; /* deletes the tree */&lt;br&gt; void deltree ( struct AVLNode *root )&lt;br&gt; {&lt;br&gt; if ( root != NULL )&lt;br&gt; {&lt;br&gt; deltree ( root -&amp;gt; left ) ;&lt;br&gt; deltree ( root -&amp;gt; right ) ;&lt;br&gt; }&lt;br&gt; free ( root ) ;&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/5364619848247355318'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/5364619848247355318'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-maintain-avl.html' title='DataStructure Program to maintain an AVL tree'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-8398346051870023412</id><published>2011-02-18T12:54:00.000+05:30</published><updated>2011-02-18T13:00:07.493+05:30</updated><title type='text'>DataStructure Program to maintain a threaded binary tree</title><content type='html'>&lt;div class=Section1&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; #include &amp;lt;alloc.h&amp;gt;&lt;br&gt; enum boolean&lt;br&gt; {&lt;br&gt; false = 0,&lt;br&gt; true = 1&lt;br&gt; } ;&lt;br&gt; struct thtree&lt;br&gt; {&lt;br&gt; enum boolean isleft ;&lt;br&gt; struct thtree *left ;&lt;br&gt; int data ;&lt;br&gt; struct thtree *right ;&lt;br&gt; enum boolen isright ;&lt;br&gt; } ;&lt;br&gt; void insert ( struct thtree **, int ) ;&lt;br&gt; void delete ( struct thtree **, int ) ;&lt;br&gt; void search ( struct thtree **, int, struct thtree **,struct thtree **, int * ) ;&lt;br&gt; void inorder ( struct thtree * ) ;&lt;br&gt; void deltree ( struct thtree ** ) ;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; struct thtree *th_head ;&lt;br&gt; th_head = NULL ; /* empty tree */&lt;br&gt; insert ( &amp;amp;th_head, 11 ) ;&lt;br&gt; insert ( &amp;amp;th_head, 9 ) ;&lt;br&gt; insert ( &amp;amp;th_head, 13 ) ;&lt;br&gt; insert ( &amp;amp;th_head, 8 ) ;&lt;br&gt; insert ( &amp;amp;th_head, 10 ) ;&lt;br&gt; insert ( &amp;amp;th_head, 12 ) ;&lt;br&gt; insert ( &amp;amp;th_head, 14 ) ;&lt;br&gt; insert ( &amp;amp;th_head, 15 ) ;&lt;br&gt; insert ( &amp;amp;th_head, 7 ) ;&lt;br&gt; clrscr( ) ;&lt;br&gt; printf ( &amp;quot;Threaded binary tree before deletion:\n&amp;quot; ) ;&lt;br&gt; inorder ( th_head ) ;&lt;br&gt; delete ( &amp;amp;th_head, 10 ) ;&lt;br&gt; printf ( &amp;quot;\nThreaded binary tree after deletion:\n&amp;quot; ) ;&lt;br&gt; inorder ( th_head ) ;&lt;br&gt; delete ( &amp;amp;th_head, 14 ) ;&lt;br&gt; printf ( &amp;quot;\nThreaded binary tree after deletion:\n&amp;quot; ) ;&lt;br&gt; inorder ( th_head ) ;&lt;br&gt; delete ( &amp;amp;th_head, 8 ) ;&lt;br&gt; printf ( &amp;quot;\nThreaded binary tree after deletion:\n&amp;quot; ) ;&lt;br&gt; inorder ( th_head ) ;&lt;br&gt; delete ( &amp;amp;th_head, 13 ) ;&lt;br&gt; printf ( &amp;quot;\nThreaded binary tree after deletion:\n&amp;quot; ) ;&lt;br&gt; inorder ( th_head ) ;&lt;br&gt; deltree ( &amp;amp;th_head ) ;&lt;br&gt; getch( ) ;&lt;br&gt; }&lt;br&gt; /* inserts a node in a threaded binary tree */&lt;br&gt; void insert ( struct thtree **s, int num )&lt;br&gt; {&lt;br&gt; struct thtree *p, *z, *head = *s ;&lt;br&gt; /* allocating a new node */&lt;br&gt; z = malloc ( sizeof ( struct thtree ) ) ;&lt;br&gt; z -&amp;gt; isleft = true ; /* indicates a thread */&lt;br&gt; z -&amp;gt; data = num ; /* assign new data */&lt;br&gt; z -&amp;gt; isright = true ; /* indicates a thread */&lt;br&gt; /* if tree is empty */&lt;br&gt; if ( *s == NULL )&lt;br&gt; {&lt;br&gt; head = malloc ( sizeof ( struct thtree ) ) ;&lt;br&gt; /* the entire tree is treated as a left sub-tree of the head node */&lt;br&gt; head -&amp;gt; isleft = false ;&lt;br&gt; head -&amp;gt; left = z ; /* z becomes leftchild of the head node */&lt;br&gt; head -&amp;gt; data = -9999 ; /* no data */&lt;br&gt; head -&amp;gt; right = head ; /* right link will always be pointing to itself */&lt;br&gt; head -&amp;gt; isright = false ;&lt;br&gt; *s = head ;&lt;br&gt; z -&amp;gt; left = head ; /* left thread to head */&lt;br&gt; z -&amp;gt; right = head ; /* right thread to head */&lt;br&gt; }&lt;br&gt; else /* if tree is non-empty */&lt;br&gt; {&lt;br&gt; p = head -&amp;gt; left ;&lt;br&gt; /* traverse till the thread is found attached to the head */&lt;br&gt; while ( p != head )&lt;br&gt; {&lt;br&gt; if ( p -&amp;gt; data &amp;gt; num )&lt;br&gt; {&lt;br&gt; if ( p -&amp;gt; isleft != true ) /* checking for a thread */&lt;br&gt; p = p -&amp;gt; left ;&lt;br&gt; else&lt;br&gt; {&lt;br&gt; z -&amp;gt; left = p -&amp;gt; left ;&lt;br&gt; p -&amp;gt; left = z ;&lt;br&gt; p -&amp;gt; isleft = false ; /* indicates a link */&lt;br&gt; z -&amp;gt; isright = true ;&lt;br&gt; z -&amp;gt; right = p ;&lt;br&gt; return ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; if ( p -&amp;gt; data &amp;lt; num )&lt;br&gt; {&lt;br&gt; if ( p -&amp;gt; isright != true )&lt;br&gt; p = p -&amp;gt; right ;&lt;br&gt; else&lt;br&gt; {&lt;br&gt; z -&amp;gt; right = p -&amp;gt; right ;&lt;br&gt; p -&amp;gt; right = z ;&lt;br&gt; p -&amp;gt; isright = false ; /* indicates a link */&lt;br&gt; z -&amp;gt; isleft = true ;&lt;br&gt; z -&amp;gt; left = p ;&lt;br&gt; return ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; }&lt;br&gt; }&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* deletes a node from the binary search tree */&lt;br&gt; void delete ( struct thtree **root, int num )&lt;br&gt; {&lt;br&gt; int found ;&lt;br&gt; struct thtree *parent, *x, *xsucc ;&lt;br&gt; /* if tree is empty */&lt;br&gt; if ( *root == NULL )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;\nTree is empty&amp;quot; ) ;&lt;br&gt; return ;&lt;br&gt; }&lt;br&gt; &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_maintain_a_threaded_binary_tree.html&quot; id=KonaLink1 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;parent&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; = x = NULL ;&lt;br&gt; /* call to search function to find the node to be deleted */&lt;br&gt; search ( root, num, &amp;amp;parent, &amp;amp;x, &amp;amp;found ) ;&lt;br&gt; /* if the node to deleted is not found */&lt;br&gt; if ( found == false )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;\nData to be deleted, not found&amp;quot; ) ;&lt;br&gt; return ;&lt;br&gt; }&lt;br&gt; /* if the node to be deleted has two children */&lt;br&gt; if ( x -&amp;gt; isleft == false &amp;amp;&amp;amp; x -&amp;gt; isright == false )&lt;br&gt; {&lt;br&gt; parent = x ;&lt;br&gt; xsucc = x -&amp;gt; right ;&lt;br&gt; while ( xsucc -&amp;gt; isleft == false )&lt;br&gt; {&lt;br&gt; parent = xsucc ;&lt;br&gt; xsucc = xsucc -&amp;gt; left ;&lt;br&gt; }&lt;br&gt; x -&amp;gt; data = xsucc -&amp;gt; data ;&lt;br&gt; x = xsucc ;&lt;br&gt; }&lt;br&gt; /* if the node to be deleted has no child */&lt;br&gt; if ( x -&amp;gt; isleft == true &amp;amp;&amp;amp; x -&amp;gt; isright == true )&lt;br&gt; {&lt;br&gt; /* if node to be deleted is a root node */&lt;br&gt; if ( parent == NULL )&lt;br&gt; {&lt;br&gt; ( *root ) -&amp;gt; left = *root ;&lt;br&gt; ( *root ) -&amp;gt; isleft = true ;&lt;br&gt; free ( x ) ;&lt;br&gt; return ;&lt;br&gt; }&lt;br&gt; if ( parent -&amp;gt; right == x )&lt;br&gt; {&lt;br&gt; parent -&amp;gt; isright = true ;&lt;br&gt; parent -&amp;gt; right = x -&amp;gt; right ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; parent -&amp;gt; isleft = true ;&lt;br&gt; parent -&amp;gt; left = x -&amp;gt; left ;&lt;br&gt; }&lt;br&gt; free ( x ) ;&lt;br&gt; return ;&lt;br&gt; }&lt;br&gt; /* if the node to be deleted has only rightchild */&lt;br&gt; if ( x -&amp;gt; isleft == true &amp;amp;&amp;amp; x -&amp;gt; isright == false )&lt;br&gt; {&lt;br&gt; /* node to be deleted is a root node */&lt;br&gt; if ( parent == NULL )&lt;br&gt; {&lt;br&gt; ( *root ) -&amp;gt; left = x -&amp;gt; right ;&lt;br&gt; free ( x ) ;&lt;br&gt; return ;&lt;br&gt; }&lt;br&gt; if ( parent -&amp;gt; left == x )&lt;br&gt; {&lt;br&gt; parent -&amp;gt; left = x -&amp;gt; right ;&lt;br&gt; x -&amp;gt; right -&amp;gt; left = x -&amp;gt; left ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; parent -&amp;gt; right = x -&amp;gt; right ;&lt;br&gt; x -&amp;gt; right -&amp;gt; left = parent ;&lt;br&gt; }&lt;br&gt; free ( x ) ;&lt;br&gt; return ;&lt;br&gt; }&lt;br&gt; /* if the node to be deleted has only left child */&lt;br&gt; if ( x -&amp;gt; isleft == false &amp;amp;&amp;amp; x -&amp;gt; isright == true )&lt;br&gt; {&lt;br&gt; /* the node to be deleted is a root node */&lt;br&gt; if ( parent == NULL )&lt;br&gt; {&lt;br&gt; parent = x ;&lt;br&gt; xsucc = x -&amp;gt; left ;&lt;br&gt; while ( xsucc -&amp;gt; right == false )&lt;br&gt; xsucc = xsucc -&amp;gt; right ;&lt;br&gt; xsucc -&amp;gt; right = *root ;&lt;br&gt; ( *root ) -&amp;gt; left = x -&amp;gt; left ;&lt;br&gt; free ( x ) ;&lt;br&gt; return ;&lt;br&gt; }&lt;br&gt; if ( parent -&amp;gt; left == x )&lt;br&gt; {&lt;br&gt; parent -&amp;gt; left = x -&amp;gt; left ;&lt;br&gt; x -&amp;gt; left -&amp;gt; right = parent ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; parent -&amp;gt; right = x -&amp;gt; left ;&lt;br&gt; x -&amp;gt; left -&amp;gt; right = x -&amp;gt; right ;&lt;br&gt; }&lt;br&gt; free ( x ) ;&lt;br&gt; return ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* returns the address of the node to be deleted, address of its parent and whether the node is found or not */&lt;br&gt; void search ( struct thtree **root, int num, struct thtree **par, struct thtree **x, int *found )&lt;br&gt; {&lt;br&gt; struct thtree *q ;&lt;br&gt; q = ( *root ) -&amp;gt; left ;&lt;br&gt; *found = false ;&lt;br&gt; *par = NULL ;&lt;br&gt; while ( q != *root )&lt;br&gt; {&lt;br&gt; /* if the node to be deleted is found */&lt;br&gt; if ( q -&amp;gt; data == num )&lt;br&gt; {&lt;br&gt; *found = true ;&lt;br&gt; *x = q ;&lt;br&gt; return ;&lt;br&gt; }&lt;br&gt; *par = q ;&lt;br&gt; if ( q -&amp;gt; data &amp;gt; num )&lt;br&gt; {&lt;br&gt; if ( q -&amp;gt; isleft == true )&lt;br&gt; {&lt;br&gt; *found = false ;&lt;br&gt; x = NULL ;&lt;br&gt; return ;&lt;br&gt; }&lt;br&gt; q = q -&amp;gt; left ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; if ( q -&amp;gt; isright == true )&lt;br&gt; {&lt;br&gt; *found = false ;&lt;br&gt; *x = NULL ;&lt;br&gt; return ;&lt;br&gt; }&lt;br&gt; q = q -&amp;gt; right ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* traverses the threaded binary tree in inorder */&lt;br&gt; void inorder ( struct thtree *root )&lt;br&gt; {&lt;br&gt; struct thtree *p ;&lt;br&gt; p = root -&amp;gt; left ;&lt;br&gt; while ( p != root )&lt;br&gt; {&lt;br&gt; while ( p -&amp;gt; isleft == false )&lt;br&gt; p = p -&amp;gt; left ;&lt;br&gt; printf ( &amp;quot;%d\t&amp;quot;, p -&amp;gt; data ) ;&lt;br&gt; while ( p -&amp;gt; isright == true )&lt;br&gt; {&lt;br&gt; p = p -&amp;gt; right ;&lt;br&gt; if ( p == root )&lt;br&gt; break ;&lt;br&gt; printf ( &amp;quot;%d\t&amp;quot;, p -&amp;gt; data ) ;&lt;br&gt; }&lt;br&gt; p = p -&amp;gt; right ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; void deltree ( struct thtree **root )&lt;br&gt; {&lt;br&gt; while ( ( *root ) -&amp;gt; left != *root )&lt;br&gt; delete ( root, ( *root ) -&amp;gt; left -&amp;gt; data ) ;&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/8398346051870023412'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/8398346051870023412'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-maintain.html' title='DataStructure Program to maintain a threaded binary tree'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-505585806246705378</id><published>2011-02-18T12:53:00.004+05:30</published><updated>2011-02-18T13:02:09.220+05:30</updated><title type='text'>DataStructure Program to implement a circular queue as a linked list</title><content type='html'>&lt;div class=Section1&gt;  &lt;h2&gt;&lt;b&gt;&lt;font size=5 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size: 18.0pt;color:white&#39;&gt;DataStructure-Program to implement a circular queue as a linked list.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/b&gt;&lt;/h2&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; #include &amp;lt;alloc.h&amp;gt;&lt;br&gt; /* structure containing a &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_implement_a_circular_queue_as_a_linked_list.html&quot; id=KonaLink1 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;data&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; part and link part */&lt;br&gt; struct node&lt;br&gt; {&lt;br&gt; int data ;&lt;br&gt; struct node * link ;&lt;br&gt; } ;&lt;br&gt; void addcirq ( struct node **, struct node **, int ) ;&lt;br&gt; int delcirq ( struct node **, struct node ** ) ;&lt;br&gt; void cirq_display ( struct node * ) ;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; struct node *front, *rear ;&lt;br&gt; front = rear = &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_implement_a_circular_queue_as_a_linked_list.html&quot; id=KonaLink2 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; ;&lt;br&gt; addcirq ( &amp;amp;front, &amp;amp;rear, 10 ) ;&lt;br&gt; addcirq ( &amp;amp;front, &amp;amp;rear, 17 ) ;&lt;br&gt; addcirq ( &amp;amp;front, &amp;amp;rear, 18 ) ;&lt;br&gt; addcirq ( &amp;amp;front, &amp;amp;rear, 5 ) ;&lt;br&gt; addcirq ( &amp;amp;front, &amp;amp;rear, 30 ) ;&lt;br&gt; addcirq ( &amp;amp;front, &amp;amp;rear, 15 ) ;&lt;br&gt; clrscr( ) ;&lt;br&gt; printf ( &amp;quot;Before deletion:\n&amp;quot; ) ;&lt;br&gt; cirq_display ( front ) ;&lt;br&gt; delcirq ( &amp;amp;front, &amp;amp;rear ) ;&lt;br&gt; delcirq ( &amp;amp;front, &amp;amp;rear ) ;&lt;br&gt; delcirq ( &amp;amp;front, &amp;amp;rear ) ;&lt;br&gt; printf ( &amp;quot;\n\nAfter deletion:\n&amp;quot; ) ;&lt;br&gt; cirq_display ( front ) ;&lt;br&gt; }&lt;br&gt; /* adds a new element at the end of queue */&lt;br&gt; void addcirq ( struct node **f, struct node **r, int item )&lt;br&gt; {&lt;br&gt; struct node *q ;&lt;br&gt; /* create new node */&lt;br&gt; q = malloc ( sizeof ( struct node ) ) ;&lt;br&gt; q -&amp;gt; data = item ;&lt;br&gt; /* if the queue is empty */&lt;br&gt; if ( *f == NULL )&lt;br&gt; *f = q ;&lt;br&gt; &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_implement_a_circular_queue_as_a_linked_list.html&quot; id=KonaLink3 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;br&gt; ( *r ) -&amp;gt; link = q ;&lt;br&gt; *r = q ;&lt;br&gt; ( *r ) -&amp;gt; link = *f ;&lt;br&gt; }&lt;br&gt; /* removes an element from front of queue */&lt;br&gt; int delcirq ( struct node **f, struct node **r )&lt;br&gt; {&lt;br&gt; struct node *q ;&lt;br&gt; int item ;&lt;br&gt; /* if queue is empty */&lt;br&gt; if ( *f == NULL )&lt;br&gt; printf ( &amp;quot;queue is empty&amp;quot; ) ;&lt;br&gt; else&lt;br&gt; {&lt;br&gt; if ( *f == *r )&lt;br&gt; {&lt;br&gt; item = ( *f ) -&amp;gt; data ;&lt;br&gt; free ( *f ) ;&lt;br&gt; *f = NULL ;&lt;br&gt; *r = NULL ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; /* delete the node */&lt;br&gt; q = *f ;&lt;br&gt; item = q -&amp;gt; data ;&lt;br&gt; *f = ( *f ) -&amp;gt; link ;&lt;br&gt; ( *r ) -&amp;gt; link = *f ;&lt;br&gt; free ( q ) ;&lt;br&gt; }&lt;br&gt; return ( item ) ;&lt;br&gt; }&lt;br&gt; return NULL ;&lt;br&gt; }&lt;br&gt; /* displays whole of the queue */&lt;br&gt; void cirq_display ( struct node *f )&lt;br&gt; {&lt;br&gt; struct node *q = f, *p = NULL ;&lt;br&gt; /* traverse the entire linked list */&lt;br&gt; while ( q != p )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;%d\t&amp;quot;, q -&amp;gt; data ) ;&lt;br&gt; q = q -&amp;gt; link ;&lt;br&gt; p = f ;&lt;br&gt; }&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/505585806246705378'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/505585806246705378'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-implement_8507.html' title='DataStructure Program to implement a circular queue as a linked list'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-5177262669359095258</id><published>2011-02-18T12:53:00.003+05:30</published><updated>2011-02-18T13:00:07.849+05:30</updated><title type='text'>DataStructure Program to maintain a double linked list</title><content type='html'>&lt;div class=Section1&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; #include &amp;lt;alloc.h&amp;gt;&lt;br&gt; /* structure representing a node of the doubly linked list */&lt;br&gt; struct dnode&lt;br&gt; {&lt;br&gt; struct dnode *prev ;&lt;br&gt; int data ;&lt;br&gt; struct dnode * next ;&lt;br&gt; } ;&lt;br&gt; void d_append ( struct dnode **, int ) ;&lt;br&gt; void d_addatbeg ( struct dnode **, int ) ;&lt;br&gt; void d_addafter ( struct dnode *, int , int ) ;&lt;br&gt; void d_display ( struct dnode * ) ;&lt;br&gt; int d_count ( struct dnode * ) ;&lt;br&gt; void d_delete ( struct dnode **, int ) ;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; struct dnode *p ;&lt;br&gt; p = NULL ; /* empty doubly linked list */&lt;br&gt; d_append ( &amp;amp;p , 11 ) ;&lt;br&gt; d_append ( &amp;amp;p , 2 ) ;&lt;br&gt; d_append ( &amp;amp;p , 14 ) ;&lt;br&gt; d_append ( &amp;amp;p , 17 ) ;&lt;br&gt; d_append ( &amp;amp;p , 99 ) ;&lt;br&gt; clrscr( ) ;&lt;br&gt; d_display ( p ) ;&lt;br&gt; printf ( &amp;quot;\nNo. of elements in the DLL = %d\n&amp;quot;, d_count ( p ) ) ;&lt;br&gt; d_addatbeg ( &amp;amp;p, 33 ) ;&lt;br&gt; d_addatbeg ( &amp;amp;p, 55 ) ;&lt;br&gt; d_display ( p ) ;&lt;br&gt; printf ( &amp;quot;\nNo. of elements in the DLL = %d\n&amp;quot;, d_count ( p ) ) ;&lt;br&gt; d_addafter ( p, 4, 66 ) ;&lt;br&gt; d_addafter ( p, 2, 96 ) ;&lt;br&gt; d_display ( p ) ;&lt;br&gt; printf ( &amp;quot;\nNo. of elements in the DLL = %d\n&amp;quot;, d_count ( p ) ) ;&lt;br&gt; d_delete ( &amp;amp;p, 55 ) ;&lt;br&gt; d_delete ( &amp;amp;p, 2 ) ;&lt;br&gt; d_delete ( &amp;amp;p, 99 ) ;&lt;br&gt; d_display ( p ) ;&lt;br&gt; printf ( &amp;quot;\nNo. of elements in the DLL = %d\n&amp;quot;, d_count ( p ) ) ;&lt;br&gt; }&lt;br&gt; /* adds a new node at the end of the doubly linked list */&lt;br&gt; void d_append ( struct dnode **s, int num )&lt;br&gt; {&lt;br&gt; struct dnode *r, *q = *s ;&lt;br&gt; /* if the linked list is empty */&lt;br&gt; if ( *s == NULL )&lt;br&gt; {&lt;br&gt; /*create a new node */&lt;br&gt; *s = malloc ( sizeof ( struct dnode ) ) ;&lt;br&gt; ( *s ) -&amp;gt; prev = NULL ;&lt;br&gt; ( *s ) -&amp;gt; data = num ;&lt;br&gt; ( *s ) -&amp;gt; next = NULL ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; /* traverse the linked list till the last node is reached */&lt;br&gt; while ( q -&amp;gt; next != NULL )&lt;br&gt; q = q -&amp;gt; next ;&lt;br&gt; /* add a new node at the end */&lt;br&gt; r = malloc ( sizeof ( struct dnode ) ) ;&lt;br&gt; r -&amp;gt; data = num ;&lt;br&gt; r -&amp;gt; next = NULL ;&lt;br&gt; r -&amp;gt; prev = q ;&lt;br&gt; q -&amp;gt; next = r ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* adds a new node at the begining of the linked list */&lt;br&gt; void d_addatbeg ( struct dnode **s, int num )&lt;br&gt; {&lt;br&gt; struct dnode *q ;&lt;br&gt; /* create a new node */&lt;br&gt; q = malloc ( sizeof ( struct dnode ) ) ;&lt;br&gt; /* assign data and pointer to the new node */&lt;br&gt; q -&amp;gt; prev = NULL ;&lt;br&gt; q -&amp;gt; data = num ;&lt;br&gt; q -&amp;gt; next = *s ;&lt;br&gt; /* make new node the head node */&lt;br&gt; ( *s ) -&amp;gt; prev = q ;&lt;br&gt; *s = q ;&lt;br&gt; }&lt;br&gt; /* adds a new node after the specified number of nodes */&lt;br&gt; void d_addafter ( struct dnode *q, int loc, int num )&lt;br&gt; {&lt;br&gt; struct dnode *temp ;&lt;br&gt; int i ;&lt;br&gt; /* skip to desired portion */&lt;br&gt; for ( i = 0 ; i &amp;lt; loc ; i++ )&lt;br&gt; {&lt;br&gt; q = q -&amp;gt; next ;&lt;br&gt; /* if end of linked list is encountered */&lt;br&gt; if ( q == NULL )&lt;br&gt; { printf ( &amp;quot;\nThere are less than %d elements&amp;quot;, loc );&lt;br&gt; return ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* insert new node */&lt;br&gt; q = q -&amp;gt; prev ;&lt;br&gt; temp = malloc ( sizeof ( struct dnode ) ) ;&lt;br&gt; temp -&amp;gt; data = num ;&lt;br&gt; temp -&amp;gt; prev = q ;&lt;br&gt; temp -&amp;gt; next = q -&amp;gt; next ;&lt;br&gt; temp -&amp;gt; next -&amp;gt; prev = temp ;&lt;br&gt; q -&amp;gt; next = temp ;&lt;br&gt; }&lt;br&gt; /* displays the contents of the linked list */&lt;br&gt; void d_display ( struct dnode *q )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;\n&amp;quot; ) ;&lt;br&gt; /* traverse the entire linked list */&lt;br&gt; while ( q != NULL )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;%2d\t&amp;quot;, q -&amp;gt; data ) ;&lt;br&gt; q = q -&amp;gt; next ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* counts the number of nodes present in the linked list */&lt;br&gt; int d_count ( struct dnode * q )&lt;br&gt; {&lt;br&gt; int c = 0 ;&lt;br&gt; /* traverse the entire linked list */&lt;br&gt; while ( q != NULL )&lt;br&gt; {&lt;br&gt; q = q -&amp;gt; next ;&lt;br&gt; c++ ;&lt;br&gt; }&lt;br&gt; return c ;&lt;br&gt; }&lt;br&gt; /* deletes the specified node from the doubly linked list */&lt;br&gt; void d_delete ( struct dnode **s, int num )&lt;br&gt; {&lt;br&gt; struct dnode *q = *s ;&lt;br&gt; /* traverse the entire linked list */&lt;br&gt; while ( q != NULL )&lt;br&gt; {&lt;br&gt; /* if node to be deleted is found */&lt;br&gt; if ( q -&amp;gt; data == num )&lt;br&gt; {&lt;br&gt; /* if node to be deleted is the first node */&lt;br&gt; if ( q == *s )&lt;br&gt; {&lt;br&gt; *s = ( *s ) -&amp;gt; next ;&lt;br&gt; ( *s ) -&amp;gt; prev = NULL ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; /* if node to be deleted is the last node */&lt;br&gt; if ( q -&amp;gt; next == NULL )&lt;br&gt; q -&amp;gt; prev -&amp;gt; next = NULL ;&lt;br&gt; else&lt;br&gt; /* if node to be deleted is any intermediate node */&lt;br&gt; {&lt;br&gt; q -&amp;gt; prev -&amp;gt; next = q -&amp;gt; next ;&lt;br&gt; q -&amp;gt; next -&amp;gt; prev = q -&amp;gt; prev ;&lt;br&gt; }&lt;br&gt; free ( q ) ;&lt;br&gt; }&lt;br&gt; return ; /* return back after deletion */&lt;br&gt; }&lt;br&gt; q = q -&amp;gt; next ; /* go to next node */&lt;br&gt; }&lt;br&gt; printf ( &amp;quot;\n%d not found.&amp;quot;, num ) ;&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/5177262669359095258'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/5177262669359095258'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-maintain_8778.html' title='DataStructure Program to maintain a double linked list'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-6653637972495214439</id><published>2011-02-18T12:53:00.002+05:30</published><updated>2011-02-18T13:00:07.663+05:30</updated><title type='text'>DataStructure Program to maintain a linked list</title><content type='html'>&lt;div class=Section1&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; #include &amp;lt;alloc.h&amp;gt;&lt;br&gt; /* structure containing a data part and link part */&lt;br&gt; struct node&lt;br&gt; {&lt;br&gt; int data ;&lt;br&gt; struct node * link ;&lt;br&gt; } ;&lt;br&gt; void append ( struct node **, int ) ;&lt;br&gt; void addatbeg ( struct node **, int ) ;&lt;br&gt; void addafter ( struct node *, int, int ) ;&lt;br&gt; void display ( struct node * ) ;&lt;br&gt; int count ( struct node * ) ;&lt;br&gt; void delete ( struct node **, int ) ;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; struct node *p ;&lt;br&gt; p = NULL ; /* empty linked list */&lt;br&gt; printf ( &amp;quot;\nNo. of elements in the Linked List = %d&amp;quot;, count ( p ) ) ;&lt;br&gt; append ( &amp;amp;p, 14 ) ;&lt;br&gt; append ( &amp;amp;p, 30 ) ;&lt;br&gt; append ( &amp;amp;p, 25 ) ;&lt;br&gt; append ( &amp;amp;p, 42 ) ;&lt;br&gt; append ( &amp;amp;p, 17 ) ;&lt;br&gt; display ( p ) ;&lt;br&gt; addatbeg ( &amp;amp;p, 999 ) ;&lt;br&gt; addatbeg ( &amp;amp;p, 888 ) ;&lt;br&gt; addatbeg ( &amp;amp;p, 777 ) ;&lt;br&gt; display ( p ) ;&lt;br&gt; addafter ( p, 7, 0 ) ;&lt;br&gt; addafter ( p, 2, 1 ) ;&lt;br&gt; addafter ( p, 5, 99 ) ;&lt;br&gt; display ( p ) ;&lt;br&gt; printf ( &amp;quot;\nNo. of elements in the Linked List = %d&amp;quot;, count ( p ) ) ;&lt;br&gt; delete ( &amp;amp;p, 99 ) ;&lt;br&gt; delete ( &amp;amp;p, 1 ) ;&lt;br&gt; delete ( &amp;amp;p, 10 ) ;&lt;br&gt; display ( p ) ;&lt;br&gt; printf ( &amp;quot;\nNo. of elements in the Linked List = %d&amp;quot;, count ( p ) ) ;&lt;br&gt; }&lt;br&gt; /* adds a node at the end of a linked list */&lt;br&gt; void append ( struct node **q, int num )&lt;br&gt; {&lt;br&gt; struct node *temp, *r ;&lt;br&gt; if ( *q == NULL ) /* if the list is empty, create first node */&lt;br&gt; {&lt;br&gt; temp = malloc ( sizeof ( struct node ) ) ;&lt;br&gt; temp -&amp;gt; data = num ;&lt;br&gt; temp -&amp;gt; link = NULL ;&lt;br&gt; *q = temp ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; temp = *q ;&lt;br&gt; /* go to last node */&lt;br&gt; while ( temp -&amp;gt; link != NULL )&lt;br&gt; temp = temp -&amp;gt; link ;&lt;br&gt; /* add node at the end */&lt;br&gt; r = malloc ( sizeof ( struct node ) ) ;&lt;br&gt; r -&amp;gt; data = num ;&lt;br&gt; r -&amp;gt; link = NULL ;&lt;br&gt; temp -&amp;gt; link = r ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* adds a new node at the beginning of the linked list */&lt;br&gt; void addatbeg ( struct node **q, int num )&lt;br&gt; {&lt;br&gt; struct node *temp ;&lt;br&gt; /* add new node */&lt;br&gt; temp = malloc ( sizeof ( struct node ) ) ;&lt;br&gt; temp -&amp;gt; data = num ;&lt;br&gt; temp -&amp;gt; link = *q ;&lt;br&gt; *q = temp ;&lt;br&gt; }&lt;br&gt; /* adds a new node after the specified number of nodes */&lt;br&gt; void addafter ( struct node *q, int loc, int num )&lt;br&gt; {&lt;br&gt; struct node *temp, *r ;&lt;br&gt; int i ;&lt;br&gt; temp = q ;&lt;br&gt; /* skip to desired portion */&lt;br&gt; for ( i = 0 ; i &amp;lt; loc ; i++ )&lt;br&gt; {&lt;br&gt; temp = temp -&amp;gt; link ;&lt;br&gt; /* if end of linked list is encountered */&lt;br&gt; if ( temp == NULL )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;\nThere are less than %d elements in list&amp;quot;, loc ) ;&lt;br&gt; return ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* insert new node */&lt;br&gt; r = malloc ( sizeof ( struct node ) ) ;&lt;br&gt; r -&amp;gt; data = num ;&lt;br&gt; r -&amp;gt; link = temp -&amp;gt; link ;&lt;br&gt; temp -&amp;gt; link = r ;&lt;br&gt; } &lt;br&gt; /* displays the contents of the linked list */&lt;br&gt; void display ( struct node *q )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;\n&amp;quot; ) ;&lt;br&gt; /* traverse the entire linked list */&lt;br&gt; while ( q != NULL )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;%d &amp;quot;, q -&amp;gt; data ) ;&lt;br&gt; q = q -&amp;gt; link ;&lt;br&gt; }&lt;br&gt; } &lt;br&gt; /* counts the number of nodes present in the linked list */&lt;br&gt; int count ( struct node * q )&lt;br&gt; {&lt;br&gt; int c = 0 ;&lt;br&gt; /* traverse the entire linked list */&lt;br&gt; while ( q != NULL )&lt;br&gt; {&lt;br&gt; q = q -&amp;gt; link ;&lt;br&gt; c++ ;&lt;br&gt; }&lt;br&gt; return c ;&lt;br&gt; }&lt;br&gt; /* deletes the specified node from the linked list */&lt;br&gt; void delete ( struct node **q, int num )&lt;br&gt; {&lt;br&gt; struct node *old, *temp ;&lt;br&gt; temp = *q ;&lt;br&gt; while ( temp != NULL )&lt;br&gt; {&lt;br&gt; if ( temp -&amp;gt; data == num )&lt;br&gt; {&lt;br&gt; /* if node to be deleted is the first node in the linked list */&lt;br&gt; if ( temp == *q )&lt;br&gt; *q = temp -&amp;gt; link ;&lt;br&gt; /* deletes the intermediate nodes in the linked list */&lt;br&gt; else&lt;br&gt; old -&amp;gt; link = temp -&amp;gt; link ;&lt;br&gt; /* free the memory occupied by the node */&lt;br&gt; free ( temp ) ;&lt;br&gt; return ;&lt;br&gt; }&lt;br&gt; /* traverse the linked list till the last node is reached */&lt;br&gt; else&lt;br&gt; {&lt;br&gt; old = temp ; /* old points to the previous node */&lt;br&gt; temp = temp -&amp;gt; link ; /* go to the next node */&lt;br&gt; }&lt;br&gt; }&lt;br&gt; printf ( &amp;quot;\nElement %d not found&amp;quot;, num ) ;&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/6653637972495214439'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/6653637972495214439'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-maintain_18.html' title='DataStructure Program to maintain a linked list'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-4716120787369928021</id><published>2011-02-18T12:53:00.001+05:30</published><updated>2011-02-18T13:00:06.853+05:30</updated><title type='text'>DataStructure Program to maintain a heap</title><content type='html'>&lt;div class=Section1&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; void restoreup ( int, int * ) ;&lt;br&gt; void restoredown ( int, int *, int ) ;&lt;br&gt; void makeheap ( int *, int ) ;&lt;br&gt; void add ( int, int *, int * ) ;&lt;br&gt; int replace ( int, int *, int ) ;&lt;br&gt; int &lt;st1:place w:st=&quot;on&quot;&gt;&lt;st1:State w:st=&quot;on&quot;&gt;del&lt;/st1:State&gt;&lt;/st1:place&gt; ( int *, int * ) ;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; int arr [20] = { 1000, 7, 10, 25, 17, 23, 27, 16, 19, 37, 42, 4, 33, 1, 5, 11 } ;&lt;br&gt; int i, n = 15 ;&lt;br&gt; clrscr( ) ;&lt;br&gt; makeheap ( arr, n ) ;&lt;br&gt; printf ( &amp;quot;Heap:\n&amp;quot; ) ;&lt;br&gt; for ( i = 1 ; i &amp;lt;= n ; i++ )&lt;br&gt; printf ( &amp;quot;%d\t&amp;quot;, arr [i] ) ;&lt;br&gt; i = 24 ;&lt;br&gt; add ( i, arr, &amp;amp;n ) ;&lt;br&gt; printf ( &amp;quot;\n\nElement added %d.\n&amp;quot;, i ) ;&lt;br&gt; printf ( &amp;quot;\nHeap after addition of an element:\n&amp;quot; ) ;&lt;br&gt; for ( i = 1 ; i &amp;lt;= n ; i++ )&lt;br&gt; printf ( &amp;quot;%d\t&amp;quot;, arr [i] ) ;&lt;br&gt; i = replace ( 2, arr, n ) ;&lt;br&gt; printf ( &amp;quot;\n\nElement replaced %d.\n&amp;quot;, i ) ;&lt;br&gt; printf ( &amp;quot;\nHeap after replacement of an element:\n&amp;quot; ) ;&lt;br&gt; for ( i = 1 ; i &amp;lt;= n ; i++ )&lt;br&gt; printf ( &amp;quot;%d\t&amp;quot;, arr [i] ) ;&lt;br&gt; i = &lt;st1:place w:st=&quot;on&quot;&gt;&lt;st1:State w:st=&quot;on&quot;&gt;del&lt;/st1:State&gt;&lt;/st1:place&gt; ( arr, &amp;amp;n ) ;&lt;br&gt; printf ( &amp;quot;\n\nElement deleted %d.\n&amp;quot;, i ) ;&lt;br&gt; printf ( &amp;quot;\nHeap after deletion of an element:\n&amp;quot; ) ;&lt;br&gt; for ( i = 1 ; i &amp;lt;= n ; i++ )&lt;br&gt; printf ( &amp;quot;%d\t&amp;quot;, arr [i] ) ;&lt;br&gt; getch( ) ;&lt;br&gt; }&lt;br&gt; void restoreup ( int i, int *arr )&lt;br&gt; {&lt;br&gt; int val ;&lt;br&gt; val = arr [i] ;&lt;br&gt; while ( arr [i / 2] &amp;lt;= val )&lt;br&gt; {&lt;br&gt; arr [i] = arr [i / 2] ;&lt;br&gt; i = i / 2 ;&lt;br&gt; }&lt;br&gt; arr [i] = val ;&lt;br&gt; }&lt;br&gt; void restoredown ( int pos, int *arr, int n )&lt;br&gt; {&lt;br&gt; int i, val ;&lt;br&gt; val = arr [pos] ;&lt;br&gt; while ( pos &amp;lt;= n / 2 )&lt;br&gt; {&lt;br&gt; i = 2 * pos ;&lt;br&gt; if ( ( i &amp;lt; n ) &amp;amp;&amp;amp; ( arr [i] &amp;lt; arr [i + 1] ) )&lt;br&gt; i++ ;&lt;br&gt; if ( val &amp;gt;= arr [i] )&lt;br&gt; break ;&lt;br&gt; arr [pos] = arr [i] ;&lt;br&gt; pos = i ;&lt;br&gt; }&lt;br&gt; arr [pos] = val ;&lt;br&gt; }&lt;br&gt; void makeheap ( int *arr, int n )&lt;br&gt; {&lt;br&gt; int i ;&lt;br&gt; for ( i = n / 2 ; i &amp;gt;= 1 ; i-- )&lt;br&gt; restoredown ( i, arr, n ) ;&lt;br&gt; }&lt;br&gt; void add ( int val, int *arr, int *n )&lt;br&gt; {&lt;br&gt; ( *n ) ++ ;&lt;br&gt; arr [*n] = val ;&lt;br&gt; restoreup ( *n, arr ) ;&lt;br&gt; }&lt;br&gt; int replace ( int i, int *arr, int n )&lt;br&gt; {&lt;br&gt; int r = arr [1] ;&lt;br&gt; arr [1] = i ;&lt;br&gt; for ( i = n / 2 ; i &amp;gt;= 1 ; i-- )&lt;br&gt; restoredown ( i, arr, n ) ;&lt;br&gt; return r ;&lt;br&gt; }&lt;br&gt; int &lt;st1:place w:st=&quot;on&quot;&gt;&lt;st1:State w:st=&quot;on&quot;&gt;del&lt;/st1:State&gt;&lt;/st1:place&gt; ( int *arr, int *n )&lt;br&gt; {&lt;br&gt; int val ;&lt;br&gt; val = arr [1] ;&lt;br&gt; arr [1] = arr [*n] ;&lt;br&gt; ( *n ) -- ;&lt;br&gt; restoredown ( 1, arr, *n ) ;&lt;br&gt; return val ;&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/4716120787369928021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/4716120787369928021'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-maintain-heap.html' title='DataStructure Program to maintain a heap'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-5887854317521195269</id><published>2011-02-18T12:53:00.000+05:30</published><updated>2011-02-18T13:00:06.698+05:30</updated><title type='text'>DataStructure Program to implement a binary search tree</title><content type='html'>&lt;div class=Section1&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; #include &amp;lt;alloc.h&amp;gt;&lt;br&gt; struct btreenode&lt;br&gt; {&lt;br&gt; struct btreenode *leftchild ;&lt;br&gt; int &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_implement_a_binary_search_tree.html&quot; id=KonaLink1 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;data&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; ;&lt;br&gt; struct btreenode *rightchild ;&lt;br&gt; } ;&lt;br&gt; void insert ( struct btreenode **, int ) ;&lt;br&gt; void inorder ( struct btreenode * ) ;&lt;br&gt; void preorder ( struct btreenode * ) ;&lt;br&gt; void postorder ( struct btreenode * ) ;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; struct btreenode *bt ;&lt;br&gt; int &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_implement_a_binary_search_tree.html&quot; id=KonaLink2 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;req&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;, i = 1, num ;&lt;br&gt; bt = &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_implement_a_binary_search_tree.html&quot; id=KonaLink3 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; ; /* empty tree */&lt;br&gt; clrscr( ) ;&lt;br&gt; printf ( &amp;quot;Specify the number of items to be inserted: &amp;quot; ) ;&lt;br&gt; scanf ( &amp;quot;%d&amp;quot;, &amp;amp;req ) ;&lt;br&gt; while ( i++ &amp;lt;= req )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;Enter the data: &amp;quot; ) ;&lt;br&gt; scanf ( &amp;quot;%d&amp;quot;, &amp;amp;num ) ;&lt;br&gt; insert ( &amp;amp;bt, num ) ;&lt;br&gt; }&lt;br&gt; printf ( &amp;quot;\nIn-order Traversal: &amp;quot; ) ;&lt;br&gt; inorder ( bt ) ;&lt;br&gt; printf ( &amp;quot;\nPre-order Traversal: &amp;quot; ) ;&lt;br&gt; preorder ( bt ) ;&lt;br&gt; printf ( &amp;quot;\nPost-order Traversal: &amp;quot; ) ;&lt;br&gt; postorder ( bt ) ;&lt;br&gt; }&lt;br&gt; /* inserts a new node in a binary search tree */&lt;br&gt; void insert ( struct btreenode **sr, int num )&lt;br&gt; {&lt;br&gt; if ( *sr == NULL )&lt;br&gt; {&lt;br&gt; *sr = malloc ( sizeof ( struct btreenode ) ) ;&lt;br&gt; ( *sr ) -&amp;gt; leftchild = NULL ;&lt;br&gt; ( *sr ) -&amp;gt; data = num ;&lt;br&gt; ( *sr ) -&amp;gt; rightchild = NULL ;&lt;br&gt; return ;&lt;br&gt; }&lt;br&gt; &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_implement_a_binary_search_tree.html&quot; id=KonaLink4 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; /* search the node to which new node will be attached */&lt;br&gt; {&lt;br&gt; /* if new data is less, traverse to left */&lt;br&gt; if ( num &amp;lt; ( *sr ) -&amp;gt; data )&lt;br&gt; insert ( &amp;amp;( ( *sr ) -&amp;gt; leftchild ), num ) ;&lt;br&gt; else&lt;br&gt; /* else traverse to right */&lt;br&gt; insert ( &amp;amp;( ( *sr ) -&amp;gt; rightchild ), num ) ;&lt;br&gt; }&lt;br&gt; return ;&lt;br&gt; }&lt;br&gt; /* traverse a binary search tree in a LDR (Left-Data-Right) fashion */&lt;br&gt; void inorder ( struct btreenode *sr )&lt;br&gt; {&lt;br&gt; if ( sr != NULL )&lt;br&gt; {&lt;br&gt; inorder ( sr -&amp;gt; leftchild ) ;&lt;br&gt; /* print the data of the node whose leftchild is NULL or the path has already been traversed */&lt;br&gt; printf ( &amp;quot;\t%d&amp;quot;, sr -&amp;gt; data ) ;&lt;br&gt; inorder ( sr -&amp;gt; rightchild ) ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; return ;&lt;br&gt; }&lt;br&gt; /* traverse a binary search tree in a DLR (Data-Left-right) fashion */&lt;br&gt; void preorder ( struct btreenode *sr )&lt;br&gt; {&lt;br&gt; if ( sr != NULL )&lt;br&gt; {&lt;br&gt; /* print the data of a node */&lt;br&gt; printf ( &amp;quot;\t%d&amp;quot;, sr -&amp;gt; data ) ;&lt;br&gt; /* traverse till leftchild is not NULL */&lt;br&gt; preorder ( sr -&amp;gt; leftchild ) ;&lt;br&gt; /* traverse till rightchild is not NULL */&lt;br&gt; preorder ( sr -&amp;gt; rightchild ) ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; return ;&lt;br&gt; }&lt;br&gt; /* traverse a binary search tree in LRD (Left-Right-Data) fashion */&lt;br&gt; void postorder ( struct btreenode *sr )&lt;br&gt; {&lt;br&gt; if ( sr != NULL )&lt;br&gt; {&lt;br&gt; postorder ( sr -&amp;gt; leftchild ) ;&lt;br&gt; postorder ( sr -&amp;gt; rightchild ) ;&lt;br&gt; printf ( &amp;quot;\t%d&amp;quot;, sr -&amp;gt; data ) ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; return ;&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/5887854317521195269'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/5887854317521195269'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-implement_18.html' title='DataStructure Program to implement a binary search tree'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-7499139127098522391</id><published>2011-02-18T12:52:00.004+05:30</published><updated>2011-02-18T13:01:31.078+05:30</updated><title type='text'>DataStructure Program to find the number of nodes in the linked list using recursion</title><content type='html'>&lt;div class=Section1&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; #include &amp;lt;alloc.h&amp;gt;&lt;br&gt; /* structure containing a data part and link part */&lt;br&gt; struct node&lt;br&gt; {&lt;br&gt; int data ;&lt;br&gt; struct node *link ;&lt;br&gt; } ;&lt;br&gt; void append ( struct node **, int ) ;&lt;br&gt; int length ( struct node * ) ;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; struct node *p ;&lt;br&gt; p = &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_find_the_number_of_nodes_in_the_linked_list_using_recursion.html&quot; id=KonaLink1 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; ; /* empty linked list */&lt;br&gt; append ( &amp;amp;p, 1 ) ;&lt;br&gt; append ( &amp;amp;p, 2 ) ;&lt;br&gt; append ( &amp;amp;p, 3 ) ;&lt;br&gt; append ( &amp;amp;p, 4 ) ;&lt;br&gt; append ( &amp;amp;p, 5 ) ;&lt;br&gt; clrscr( ) ;&lt;br&gt; printf ( &amp;quot;Length of linked list = %d&amp;quot;, length ( p ) ) ;&lt;br&gt; }&lt;br&gt; /* adds a node at the end of a linked list */&lt;br&gt; void append ( struct node **q, int num )&lt;br&gt; {&lt;br&gt; struct node *temp ;&lt;br&gt; temp = *q ;&lt;br&gt; if ( *q == NULL ) /* if the list is empty, create first node */&lt;br&gt; {&lt;br&gt; *q = malloc ( sizeof ( struct node ) ) ;&lt;br&gt; temp = *q ;&lt;br&gt; }&lt;br&gt; &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_find_the_number_of_nodes_in_the_linked_list_using_recursion.html&quot; id=KonaLink2 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;br&gt; {&lt;br&gt; /* go to last node */&lt;br&gt; while ( temp -&amp;gt; link != NULL )&lt;br&gt; temp = temp -&amp;gt; link ;&lt;br&gt; /* add node at the end */&lt;br&gt; temp -&amp;gt; link = malloc ( sizeof ( struct node ) ) ;&lt;br&gt; temp = temp -&amp;gt; link ;&lt;br&gt; }&lt;br&gt; /* assign data to the last node */&lt;br&gt; temp -&amp;gt; data = num ;&lt;br&gt; temp -&amp;gt; link = NULL ;&lt;br&gt; }&lt;br&gt; /* counts the number of nodes in a linked list */&lt;br&gt; int length ( struct node *q )&lt;br&gt; {&lt;br&gt; static int l ;&lt;br&gt; /* if list is empty or if NULL is encountered */&lt;br&gt; if ( q == NULL )&lt;br&gt; return ( 0 ) ;&lt;br&gt; else&lt;br&gt; {&lt;br&gt; /* go to next node */&lt;br&gt; l = 1 + length ( q -&amp;gt; link ) ;&lt;br&gt; return ( l ) ;&lt;br&gt; }&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/7499139127098522391'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/7499139127098522391'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-find-number-of.html' title='DataStructure Program to find the number of nodes in the linked list using recursion'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-2994918607054471040</id><published>2011-02-18T12:52:00.003+05:30</published><updated>2011-02-18T13:00:06.338+05:30</updated><title type='text'>DataStructure Program to evaluate an epression entered in postfix form</title><content type='html'>&lt;div class=Section1&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; #include &amp;lt;stdlib.h&amp;gt;&lt;br&gt; #include &amp;lt;math.h&amp;gt;&lt;br&gt; #include &amp;lt;ctype.h&amp;gt;&lt;br&gt; #define MAX 50&lt;br&gt; struct postfix&lt;br&gt; {&lt;br&gt; int stack[MAX] ;&lt;br&gt; int top, nn ;&lt;br&gt; &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_evaluate_an_epression_entered_in_postfix_form.html&quot; id=KonaLink1 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;char&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; *s ;&lt;br&gt; } ;&lt;br&gt; void initpostfix ( struct postfix * ) ;&lt;br&gt; void setexpr ( struct postfix *, char * ) ;&lt;br&gt; void push ( struct postfix *, int ) ;&lt;br&gt; int pop ( struct postfix * ) ;&lt;br&gt; void calculate ( struct postfix * ) ;&lt;br&gt; void show ( struct postfix ) ;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; struct postfix q ;&lt;br&gt; char expr[MAX] ;&lt;br&gt; clrscr( ) ;&lt;br&gt; initpostfix ( &amp;amp;q ) ;&lt;br&gt; printf ( &amp;quot;\nEnter postfix &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_evaluate_an_epression_entered_in_postfix_form.html&quot; id=KonaLink2 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;expression&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; to be evaluated: &amp;quot; ) ;&lt;br&gt; gets ( expr ) ;&lt;br&gt; setexpr ( &amp;amp;q, expr ) ;&lt;br&gt; calculate ( &amp;amp;q ) ;&lt;br&gt; show ( q ) ;&lt;br&gt; getch( ) ;&lt;br&gt; }&lt;br&gt; /* initializes data members */&lt;br&gt; void initpostfix ( struct postfix *p )&lt;br&gt; {&lt;br&gt; p -&amp;gt; top = -1 ;&lt;br&gt; }&lt;br&gt; /* sets s to point to the given expr. */&lt;br&gt; void setexpr ( struct postfix *p, char *str )&lt;br&gt; {&lt;br&gt; p -&amp;gt; s = str ;&lt;br&gt; }&lt;br&gt; /* adds digit to the stack */&lt;br&gt; void push ( struct postfix *p, int item )&lt;br&gt; {&lt;br&gt; if ( p -&amp;gt; top == MAX - 1 )&lt;br&gt; printf ( &amp;quot;\nStack is full.&amp;quot; ) ;&lt;br&gt; &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_evaluate_an_epression_entered_in_postfix_form.html&quot; id=KonaLink3 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;br&gt; {&lt;br&gt; p -&amp;gt; top++ ;&lt;br&gt; p -&amp;gt; stack[p -&amp;gt; top] = item ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* pops digit from the stack */&lt;br&gt; int pop ( struct postfix *p )&lt;br&gt; {&lt;br&gt; int data ;&lt;br&gt; if ( p -&amp;gt; top == -1 )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;\nStack is empty.&amp;quot; ) ;&lt;br&gt; return &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_evaluate_an_epression_entered_in_postfix_form.html&quot; id=KonaLink4 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; ;&lt;br&gt; }&lt;br&gt; data = p -&amp;gt; stack[p -&amp;gt; top] ;&lt;br&gt; p -&amp;gt; top-- ;&lt;br&gt; return data ;&lt;br&gt; }&lt;br&gt; /* evaluates the postfix expression */&lt;br&gt; void calculate( struct postfix *p )&lt;br&gt; {&lt;br&gt; int n1, n2, n3 ;&lt;br&gt; while ( *( p -&amp;gt; s ) )&lt;br&gt; {&lt;br&gt; /* skip whitespace, if any */&lt;br&gt; if ( *( p -&amp;gt; s ) == &#39; &#39; || *( p -&amp;gt; s ) == &#39;\t&#39; )&lt;br&gt; {&lt;br&gt; p -&amp;gt; s++ ;&lt;br&gt; continue ;&lt;br&gt; }&lt;br&gt; /* if digit is encountered */&lt;br&gt; if ( isdigit ( *( p -&amp;gt; s ) ) )&lt;br&gt; {&lt;br&gt; p -&amp;gt; nn = *( p -&amp;gt; s ) - &#39;0&#39; ;&lt;br&gt; push ( p, p -&amp;gt; nn ) ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; /* if operator is encountered */&lt;br&gt; n1 = pop ( p ) ;&lt;br&gt; n2 = pop ( p ) ;&lt;br&gt; switch ( *( p -&amp;gt; s ) )&lt;br&gt; {&lt;br&gt; case &#39;+&#39; :&lt;br&gt; n3 = n2 + n1 ;&lt;br&gt; break ;&lt;br&gt; case &#39;-&#39; :&lt;br&gt; n3 = n2 - n1 ;&lt;br&gt; break ;&lt;br&gt; case &#39;/&#39; :&lt;br&gt; n3 = n2 / n1 ;&lt;br&gt; break ;&lt;br&gt; case &#39;*&#39; :&lt;br&gt; n3 = n2 * n1 ;&lt;br&gt; break ;&lt;br&gt; case &#39;%&#39; :&lt;br&gt; n3 = n2 % n1 ;&lt;br&gt; break ;&lt;br&gt; case &#39;$&#39; :&lt;br&gt; n3 = pow ( n2 , n1 ) ;&lt;br&gt; break ;&lt;br&gt; default :&lt;br&gt; printf ( &amp;quot;Unknown operator&amp;quot; ) ;&lt;br&gt; exit ( 1 ) ;&lt;br&gt; }&lt;br&gt; push ( p, n3 ) ;&lt;br&gt; }&lt;br&gt; p -&amp;gt; s++ ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* displays the result */&lt;br&gt; void show ( struct postfix p )&lt;br&gt; {&lt;br&gt; p.nn = pop ( &amp;amp;p ) ;&lt;br&gt; printf ( &amp;quot;Result is: %d&amp;quot;, p.nn ) ;&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/2994918607054471040'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/2994918607054471040'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-evaluate.html' title='DataStructure Program to evaluate an epression entered in postfix form'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-3759715240030142607</id><published>2011-02-18T12:52:00.002+05:30</published><updated>2011-02-18T13:00:06.024+05:30</updated><title type='text'>DataStructure Program to create a 3-tuple from a given matrix</title><content type='html'>&lt;div class=Section1&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; #include &amp;lt;alloc.h&amp;gt;&lt;br&gt; #define MAX1 3&lt;br&gt; #define MAX2 3&lt;br&gt; struct sparse&lt;br&gt; {&lt;br&gt; int *sp ;&lt;br&gt; int row ;&lt;br&gt; } ;&lt;br&gt; void initsparse ( struct sparse * ) ;&lt;br&gt; void create_array ( struct sparse * ) ;&lt;br&gt; void display ( struct sparse ) ;&lt;br&gt; int count ( struct sparse ) ;&lt;br&gt; void create_tuple ( struct sparse *, struct sparse ) ;&lt;br&gt; void display_tuple ( struct sparse ) ;&lt;br&gt; void delsparse ( struct sparse * ) ;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; struct sparse s1, s2 ;&lt;br&gt; int c ;&lt;br&gt; clrscr( );&lt;br&gt; initsparse ( &amp;amp;s1 ) ;&lt;br&gt; initsparse ( &amp;amp;s2 ) ;&lt;br&gt; create_array ( &amp;amp;s1 ) ;&lt;br&gt; printf ( &amp;quot;\nElements in Sparse Matrix: &amp;quot; ) ;&lt;br&gt; display ( s1 ) ;&lt;br&gt; c = count ( s1 ) ;&lt;br&gt; printf ( &amp;quot;\n\nNumber of non-zero elements: %d&amp;quot;, c ) ;&lt;br&gt; create_tuple ( &amp;amp;s2, s1 ) ;&lt;br&gt; printf ( &amp;quot;\n\nArray of non-zero elements: &amp;quot; ) ;&lt;br&gt; display_tuple ( s2 ) ;&lt;br&gt; delsparse ( &amp;amp;s1 ) ;&lt;br&gt; delsparse ( &amp;amp;s2 ) ;&lt;br&gt; getch( ) ;&lt;br&gt; }&lt;br&gt; /* initialises element of structure */&lt;br&gt; void initsparse ( struct sparse *p )&lt;br&gt; {&lt;br&gt; p -&amp;gt; sp = NULL ;&lt;br&gt; }&lt;br&gt; /* dynamically creates the matrix of size MAX1 x MAX2 */&lt;br&gt; void create_array ( struct sparse *p )&lt;br&gt; {&lt;br&gt; int n, i ;&lt;br&gt; p -&amp;gt; sp = ( int * ) malloc ( MAX1 * MAX2 * sizeof ( int ) ) ;&lt;br&gt; for ( i = 0 ; i &amp;lt; MAX1 * MAX2 ; i++ )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;Enter element no. %d: &amp;quot;, i ) ;&lt;br&gt; scanf ( &amp;quot;%d&amp;quot;, &amp;amp;n ) ;&lt;br&gt; * ( p -&amp;gt; sp + i ) = n ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* displays the contents of the matrix */&lt;br&gt; void display ( struct sparse p )&lt;br&gt; {&lt;br&gt; int i ;&lt;br&gt; /* traverses the entire matrix */&lt;br&gt; for ( i = 0 ; i &amp;lt; MAX1 * MAX2 ; i++ )&lt;br&gt; {&lt;br&gt; /* positions the &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_create_a_three_tuple_from_a_given_matrix.html&quot; id=KonaLink0 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;cursor&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; to the new line for every new row */&lt;br&gt; if ( i % MAX2 == 0 )&lt;br&gt; printf ( &amp;quot;\n&amp;quot; ) ;&lt;br&gt; printf ( &amp;quot;%d\t&amp;quot;, * ( p.sp + i ) ) ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* counts the number of non-zero elements */&lt;br&gt; int count ( struct sparse p )&lt;br&gt; {&lt;br&gt; int cnt = 0, i ;&lt;br&gt; for ( i = 0 ; i &amp;lt; MAX1 * MAX2 ; i++ )&lt;br&gt; {&lt;br&gt; if ( * ( p.sp + i ) != 0 )&lt;br&gt; cnt++ ;&lt;br&gt; }&lt;br&gt; return cnt ;&lt;br&gt; }&lt;br&gt; /* creates an array that stores information about non-zero elements */&lt;br&gt; void create_tuple ( struct sparse *p, struct sparse s )&lt;br&gt; {&lt;br&gt; int r = 0 , c = -1, l = -1, i ;&lt;br&gt; p -&amp;gt; row = count ( s ) + 1 ;&lt;br&gt; p -&amp;gt; sp = ( int * ) malloc ( p -&amp;gt; row * 3 * sizeof ( int ) ) ;&lt;br&gt; * ( p -&amp;gt; sp + 0 ) = MAX1 ;&lt;br&gt; * ( p -&amp;gt; sp + 1 ) = MAX2 ;&lt;br&gt; * ( p -&amp;gt; sp + 2 ) = p -&amp;gt; row - 1 ;&lt;br&gt; l = 2 ;&lt;br&gt; for ( i = 0 ; i &amp;lt; MAX1 * MAX2 ; i++ )&lt;br&gt; {&lt;br&gt; c++ ;&lt;br&gt; /* sets the row and column values */&lt;br&gt; if ( ( ( i % MAX2 ) == 0 ) &amp;amp;&amp;amp; ( i != 0 ) )&lt;br&gt; {&lt;br&gt; r++ ;&lt;br&gt; c = 0 ;&lt;br&gt; }&lt;br&gt; /* checks for non-zero element row, column and non-zero element value is assigned to the matrix */&lt;br&gt; if ( * ( s.sp + i ) != 0 )&lt;br&gt; {&lt;br&gt; l++ ;&lt;br&gt; * ( p -&amp;gt; sp + l ) = r ;&lt;br&gt; l++ ;&lt;br&gt; * ( p -&amp;gt; sp + l ) = c ;&lt;br&gt; l++ ;&lt;br&gt; * ( p -&amp;gt; sp + l ) = * ( s.sp + i ) ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* displays the contents of 3-tuple */&lt;br&gt; void display_tuple ( struct sparse p )&lt;br&gt; {&lt;br&gt; int i ;&lt;br&gt; for ( i = 0 ; i &amp;lt; p.row * 3 ; i++ )&lt;br&gt; {&lt;br&gt; if ( i % 3 == 0 )&lt;br&gt; printf ( &amp;quot;\n&amp;quot; ) ;&lt;br&gt; printf ( &amp;quot;%d\t&amp;quot;, * ( p.sp + i ) ) ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* deallocates memory */&lt;br&gt; void delsparse ( struct sparse *p )&lt;br&gt; { free ( p -&amp;gt; sp ) ;&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/3759715240030142607'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/3759715240030142607'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-create-3-tuple.html' title='DataStructure Program to create a 3-tuple from a given matrix'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-7223531947880996804</id><published>2011-02-18T12:52:00.001+05:30</published><updated>2011-02-18T13:00:05.750+05:30</updated><title type='text'>DataStructure Program to convert expression in postfix form to prefix form</title><content type='html'>&lt;div class=Section1&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; #include &amp;lt;string.h&amp;gt;&lt;br&gt; #define MAX 50&lt;br&gt; struct postfix&lt;br&gt; {&lt;br&gt; &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_convert_expression_in_postfix_to_form.html&quot; id=KonaLink0 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;char&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; stack[MAX][MAX], target[MAX] ;&lt;br&gt; char temp1[2], temp2[2] ;&lt;br&gt; char str1[MAX], str2[MAX], str3[MAX] ;&lt;br&gt; int i, top ;&lt;br&gt; } ;&lt;br&gt; void initpostfix ( struct postfix * ) ;&lt;br&gt; void setexpr ( struct postfix *, char * ) ;&lt;br&gt; void push ( struct postfix *, char * ) ;&lt;br&gt; void pop ( struct postfix *, char * ) ;&lt;br&gt; void convert ( struct postfix * ) ;&lt;br&gt; void show ( struct postfix ) ;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; struct postfix q ;&lt;br&gt; char expr[MAX] ;&lt;br&gt; clrscr( ) ;&lt;br&gt; initpostfix ( &amp;amp;q ) ;&lt;br&gt; printf ( &amp;quot;\nEnter an expression in postfix form: &amp;quot; ) ;&lt;br&gt; gets ( expr ) ;&lt;br&gt; setexpr ( &amp;amp;q, &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_convert_expression_in_postfix_to_form.html&quot; id=KonaLink1 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;expr&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; ) ;&lt;br&gt; convert ( &amp;amp;q ) ;&lt;br&gt; printf ( &amp;quot;\nThe Prefix &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_convert_expression_in_postfix_to_form.html&quot; id=KonaLink2 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;expression&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; is: &amp;quot; ) ;&lt;br&gt; show ( q ) ;&lt;br&gt; getch( ) ;&lt;br&gt; }&lt;br&gt; /* initializes the elements of the structure */&lt;br&gt; void initpostfix ( struct postfix *p )&lt;br&gt; {&lt;br&gt; p -&amp;gt; i = 0 ;&lt;br&gt; p -&amp;gt; top = -1 ;&lt;br&gt; strcpy ( p -&amp;gt; target, &amp;quot;&amp;quot; ) ;&lt;br&gt; }&lt;br&gt; /* copies given expr. to target string */&lt;br&gt; void setexpr ( struct postfix *p, char *c )&lt;br&gt; {&lt;br&gt; strcpy ( p -&amp;gt; target, c ) ;&lt;br&gt; }&lt;br&gt; /* adds an operator to the stack */&lt;br&gt; void push ( struct postfix *p, char *str )&lt;br&gt; {&lt;br&gt; if ( p -&amp;gt; top == MAX - 1 )&lt;br&gt; printf ( &amp;quot;\nStack is full.&amp;quot; ) ;&lt;br&gt; else&lt;br&gt; {&lt;br&gt; p -&amp;gt; top++ ;&lt;br&gt; strcpy ( p -&amp;gt; stack[p -&amp;gt; top], str ) ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* pops an element from the &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_convert_expression_in_postfix_to_form.html&quot; id=KonaLink3 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;stack&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; */&lt;br&gt; void pop ( struct postfix *p, char *a )&lt;br&gt; {&lt;br&gt; if ( p -&amp;gt; top == -1 )&lt;br&gt; printf ( &amp;quot;\nStack is empty.&amp;quot; ) ;&lt;br&gt; &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_convert_expression_in_postfix_to_form.html&quot; id=KonaLink4 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;br&gt; {&lt;br&gt; strcpy ( a, p -&amp;gt; stack[p -&amp;gt; top] ) ;&lt;br&gt; p -&amp;gt; top-- ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* converts given expr. to prefix form */&lt;br&gt; void convert ( struct postfix *p )&lt;br&gt; {&lt;br&gt; while ( p -&amp;gt; target[p -&amp;gt; i] != &#39;\0&#39; )&lt;br&gt; {&lt;br&gt; /* skip whitespace, if any */&lt;br&gt; if ( p -&amp;gt; target[p -&amp;gt; i] == &#39; &#39;)&lt;br&gt; p -&amp;gt; i++ ;&lt;br&gt; if( p -&amp;gt; target[p -&amp;gt; i] == &#39;%&#39; || p -&amp;gt; target[p -&amp;gt; i] == &#39;*&#39; || p -&amp;gt; target[p -&amp;gt; i] == &#39;-&#39; || p -&amp;gt; target[p -&amp;gt; i] == &#39;+&#39; || p -&amp;gt; target[p -&amp;gt; i] == &#39;/&#39; || p -&amp;gt; target[p -&amp;gt; i] == &#39;$&#39; )&lt;br&gt; {&lt;br&gt; pop ( p, p -&amp;gt; str2 ) ;&lt;br&gt; pop ( p, p -&amp;gt; str3 ) ;&lt;br&gt; p -&amp;gt; temp1[0] = p -&amp;gt; target[ p -&amp;gt; i] ;&lt;br&gt; p -&amp;gt; temp1[1] = &#39;\0&#39; ;&lt;br&gt; strcpy ( p -&amp;gt; str1, p -&amp;gt; temp1 ) ;&lt;br&gt; strcat ( p -&amp;gt; str1, p -&amp;gt; str3 ) ;&lt;br&gt; strcat ( p -&amp;gt; str1, p -&amp;gt; str2 ) ;&lt;br&gt; push ( p, p -&amp;gt; str1 ) ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; p -&amp;gt; temp1[0] = p -&amp;gt; target[p -&amp;gt; i] ;&lt;br&gt; p -&amp;gt; temp1[1] = &#39;\0&#39; ;&lt;br&gt; strcpy ( p -&amp;gt; temp2, p -&amp;gt; temp1 ) ;&lt;br&gt; push ( p, p -&amp;gt; temp2 ) ;&lt;br&gt; }&lt;br&gt; p -&amp;gt; i++ ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* displays the prefix form of expr. */&lt;br&gt; void show ( struct postfix p )&lt;br&gt; {&lt;br&gt; char *temp = p.stack[0] ;&lt;br&gt; while ( *temp )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;%c &amp;quot;, *temp ) ;&lt;br&gt; temp++ ;&lt;br&gt; }&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/7223531947880996804'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/7223531947880996804'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-convert.html' title='DataStructure Program to convert expression in postfix form to prefix form'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-8921539200483115835</id><published>2011-02-18T12:52:00.000+05:30</published><updated>2011-02-18T13:00:05.526+05:30</updated><title type='text'>DataStructure Program to copy one linked list into another using recursion</title><content type='html'>&lt;div class=Section1&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; #include &amp;lt;alloc.h&amp;gt;&lt;br&gt; /* structure containing a data part and link part */&lt;br&gt; struct node&lt;br&gt; {&lt;br&gt; int data ;&lt;br&gt; struct node *link ;&lt;br&gt; } ;&lt;br&gt; void append ( struct node **, int ) ;&lt;br&gt; void copy ( struct node *, struct node ** ) ;&lt;br&gt; void display ( struct node * ) ;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; struct node *first, *second ;&lt;br&gt; first = second = NULL ; /* empty linked lists */&lt;br&gt; append ( &amp;amp;first, 1 ) ;&lt;br&gt; append ( &amp;amp;first, 2 ) ;&lt;br&gt; append ( &amp;amp;first, 3 ) ;&lt;br&gt; append ( &amp;amp;first, 4 ) ;&lt;br&gt; append ( &amp;amp;first, 5 ) ;&lt;br&gt; append ( &amp;amp;first, 6 ) ;&lt;br&gt; append ( &amp;amp;first, 7 ) ;&lt;br&gt; clrscr( ) ;&lt;br&gt; display ( first ) ;&lt;br&gt; copy ( first, &amp;amp;second ) ;&lt;br&gt; display ( second ) ;&lt;br&gt; }&lt;br&gt; /* adds a node at the end of the linked list */&lt;br&gt; void append ( struct node **q, int num )&lt;br&gt; {&lt;br&gt; struct node *temp ;&lt;br&gt; temp = *q ;&lt;br&gt; if ( *q == NULL ) /* if the list is empty, create first node */&lt;br&gt; {&lt;br&gt; *q = malloc ( sizeof ( struct node ) ) ;&lt;br&gt; temp = *q ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; /* go to last node */&lt;br&gt; while ( temp -&amp;gt; link != NULL )&lt;br&gt; temp = temp -&amp;gt; link ;&lt;br&gt; /* add node at the end */&lt;br&gt; temp -&amp;gt; link = malloc ( sizeof ( struct node ) ) ;&lt;br&gt; temp = temp -&amp;gt; link ;&lt;br&gt; }&lt;br&gt; /* assign data to the last node */&lt;br&gt; temp -&amp;gt; data = num ;&lt;br&gt; temp -&amp;gt; link = NULL ;&lt;br&gt; }&lt;br&gt; /* copies a linked list into another */&lt;br&gt; void copy ( struct node *q, struct node **s )&lt;br&gt; {&lt;br&gt; if ( q != NULL )&lt;br&gt; {&lt;br&gt; *s = malloc ( sizeof ( struct node ) ) ;&lt;br&gt; ( *s ) -&amp;gt; data = q -&amp;gt; data ;&lt;br&gt; ( *s ) -&amp;gt; link = NULL ;&lt;br&gt; copy ( q -&amp;gt; link, &amp;amp;( ( *s ) -&amp;gt; link ) ) ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* displays the contents of the linked list */&lt;br&gt; void display ( struct node *q )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;\n&amp;quot; ) ;&lt;br&gt; /* traverse the entire linked list */&lt;br&gt; while ( q != NULL )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;%d &amp;quot;, q -&amp;gt; data ) ;&lt;br&gt; q = q -&amp;gt; link ;&lt;br&gt; }&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/8921539200483115835'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/8921539200483115835'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-copy-one.html' title='DataStructure Program to copy one linked list into another using recursion'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-7746937861773819744</id><published>2011-02-18T12:51:00.000+05:30</published><updated>2011-02-18T13:01:59.614+05:30</updated><title type='text'>DataStructure Program to convert expression in postfix form to prefix form</title><content type='html'>&lt;div class=Section1&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; #include &amp;lt;string.h&amp;gt;&lt;br&gt; #define MAX 50&lt;br&gt; struct postfix&lt;br&gt; {&lt;br&gt; char stack[MAX][MAX], target[MAX] ;&lt;br&gt; char temp1[2], temp2[2] ;&lt;br&gt; char str1[MAX], str2[MAX], str3[MAX] ;&lt;br&gt; int i, top ;&lt;br&gt; } ;&lt;br&gt; void initpostfix ( struct postfix * ) ;&lt;br&gt; void setexpr ( struct postfix *, char * ) ;&lt;br&gt; void push ( struct postfix *, char * ) ;&lt;br&gt; void &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_convert_expression_in_postfix_to_form.html&quot; id=KonaLink0 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;pop&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; ( struct postfix *, char * ) ;&lt;br&gt; void convert ( struct postfix * ) ;&lt;br&gt; void show ( struct postfix ) ;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; struct postfix q ;&lt;br&gt; char expr[MAX] ;&lt;br&gt; clrscr( ) ;&lt;br&gt; initpostfix ( &amp;amp;q ) ;&lt;br&gt; printf ( &amp;quot;\nEnter an expression in postfix form: &amp;quot; ) ;&lt;br&gt; gets ( expr ) ;&lt;br&gt; setexpr ( &amp;amp;q, expr ) ;&lt;br&gt; convert ( &amp;amp;q ) ;&lt;br&gt; printf ( &amp;quot;\nThe Prefix expression is: &amp;quot; ) ;&lt;br&gt; show ( q ) ;&lt;br&gt; getch( ) ;&lt;br&gt; }&lt;br&gt; /* initializes the elements of the structure */&lt;br&gt; void initpostfix ( struct postfix *p )&lt;br&gt; {&lt;br&gt; p -&amp;gt; i = 0 ;&lt;br&gt; p -&amp;gt; top = -1 ;&lt;br&gt; strcpy ( p -&amp;gt; target, &amp;quot;&amp;quot; ) ;&lt;br&gt; }&lt;br&gt; /* copies given expr. to target string */&lt;br&gt; void setexpr ( struct postfix *p, char *c )&lt;br&gt; {&lt;br&gt; strcpy ( p -&amp;gt; target, c ) ;&lt;br&gt; }&lt;br&gt; /* adds an operator to the stack */&lt;br&gt; void push ( struct postfix *p, char *str )&lt;br&gt; {&lt;br&gt; if ( p -&amp;gt; top == MAX - 1 )&lt;br&gt; printf ( &amp;quot;\nStack is full.&amp;quot; ) ;&lt;br&gt; else&lt;br&gt; {&lt;br&gt; p -&amp;gt; top++ ;&lt;br&gt; strcpy ( p -&amp;gt; stack[p -&amp;gt; top], str ) ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* pops an element from the stack */&lt;br&gt; void pop ( struct postfix *p, char *a )&lt;br&gt; {&lt;br&gt; if ( p -&amp;gt; top == -1 )&lt;br&gt; printf ( &amp;quot;\nStack is empty.&amp;quot; ) ;&lt;br&gt; else&lt;br&gt; {&lt;br&gt; strcpy ( a, p -&amp;gt; stack[p -&amp;gt; top] ) ;&lt;br&gt; p -&amp;gt; top-- ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* converts given expr. to prefix form */&lt;br&gt; void convert ( struct postfix *p )&lt;br&gt; {&lt;br&gt; while ( p -&amp;gt; target[p -&amp;gt; i] != &#39;\0&#39; )&lt;br&gt; {&lt;br&gt; /* skip whitespace, if any */&lt;br&gt; if ( p -&amp;gt; target[p -&amp;gt; i] == &#39; &#39;)&lt;br&gt; p -&amp;gt; i++ ;&lt;br&gt; if( p -&amp;gt; target[p -&amp;gt; i] == &#39;%&#39; || p -&amp;gt; target[p -&amp;gt; i] == &#39;*&#39; || p -&amp;gt; target[p -&amp;gt; i] == &#39;-&#39; || p -&amp;gt; target[p -&amp;gt; i] == &#39;+&#39; || p -&amp;gt; target[p -&amp;gt; i] == &#39;/&#39; || p -&amp;gt; target[p -&amp;gt; i] == &#39;$&#39; )&lt;br&gt; {&lt;br&gt; pop ( p, p -&amp;gt; str2 ) ;&lt;br&gt; pop ( p, p -&amp;gt; str3 ) ;&lt;br&gt; p -&amp;gt; temp1[0] = p -&amp;gt; target[ p -&amp;gt; i] ;&lt;br&gt; p -&amp;gt; temp1[1] = &#39;\0&#39; ;&lt;br&gt; strcpy ( p -&amp;gt; str1, p -&amp;gt; temp1 ) ;&lt;br&gt; strcat ( p -&amp;gt; str1, p -&amp;gt; str3 ) ;&lt;br&gt; strcat ( p -&amp;gt; str1, p -&amp;gt; str2 ) ;&lt;br&gt; push ( p, p -&amp;gt; str1 ) ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; p -&amp;gt; temp1[0] = p -&amp;gt; target[p -&amp;gt; i] ;&lt;br&gt; p -&amp;gt; temp1[1] = &#39;\0&#39; ;&lt;br&gt; strcpy ( p -&amp;gt; temp2, p -&amp;gt; temp1 ) ;&lt;br&gt; push ( p, p -&amp;gt; temp2 ) ;&lt;br&gt; }&lt;br&gt; p -&amp;gt; i++ ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* displays the prefix form of expr. */&lt;br&gt; void show ( struct postfix p )&lt;br&gt; {&lt;br&gt; char *temp = p.stack[0] ;&lt;br&gt; while ( *temp )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;%c &amp;quot;, *temp ) ;&lt;br&gt; temp++ ;&lt;br&gt; }&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/7746937861773819744'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/7746937861773819744'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-convert_6262.html' title='DataStructure Program to convert expression in postfix form to prefix form'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-9223123628334895681</id><published>2011-02-18T12:50:00.004+05:30</published><updated>2011-02-18T13:01:26.067+05:30</updated><title type='text'>DataStructure Program to convert an expression in postfix form to an infix form</title><content type='html'>&lt;div class=Section1&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; #include &amp;lt;string.h&amp;gt;&lt;br&gt; #define MAX 50&lt;br&gt; struct postfix&lt;br&gt; {&lt;br&gt; char stack[MAX][MAX], target[MAX] ;&lt;br&gt; char temp1[2], temp2[2] ;&lt;br&gt; char str1[MAX], str2[MAX], str3[MAX] ;&lt;br&gt; int i, top ;&lt;br&gt; } ;&lt;br&gt; void initpostfix ( struct postfix * ) ;&lt;br&gt; void setexpr ( struct postfix *, char * ) ;&lt;br&gt; void push ( struct postfix *, char * ) ;&lt;br&gt; void &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_convert_an_expression_in_postfix_form_to_an_infix_form.html&quot; id=KonaLink0 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;pop&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; ( struct postfix *, char * ) ;&lt;br&gt; void convert ( struct postfix * ) ;&lt;br&gt; void show ( struct postfix ) ;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; struct postfix q ;&lt;br&gt; char expr[MAX] ;&lt;br&gt; clrscr( ) ;&lt;br&gt; initpostfix ( &amp;amp;q ) ;&lt;br&gt; printf ( &amp;quot;\nEnter an expression in postfix form: &amp;quot; ) ;&lt;br&gt; gets ( expr ) ; &lt;br&gt; setexpr ( &amp;amp;q, expr ) ;&lt;br&gt; convert ( &amp;amp;q ) ;&lt;br&gt; printf ( &amp;quot;\nThe infix expression is: &amp;quot; ) ;&lt;br&gt; show ( q ) ;&lt;br&gt; getch( ) ;&lt;br&gt; }&lt;br&gt; /* initializes data member */&lt;br&gt; void initpostfix ( struct postfix *p )&lt;br&gt; {&lt;br&gt; p -&amp;gt; i = 0 ;&lt;br&gt; p -&amp;gt; top = -1 ;&lt;br&gt; strcpy ( p -&amp;gt; target, &amp;quot;&amp;quot; ) ;&lt;br&gt; }&lt;br&gt; /* copies given expression to target string */&lt;br&gt; void setexpr ( struct postfix *p, char *c )&lt;br&gt; {&lt;br&gt; strcpy ( p -&amp;gt; target, c ) ;&lt;br&gt; }&lt;br&gt; /* adds an expr. to the stack */&lt;br&gt; void push ( struct postfix *p, char *str )&lt;br&gt; {&lt;br&gt; if ( p -&amp;gt; top == MAX - 1 )&lt;br&gt; printf ( &amp;quot;\nStack is full.&amp;quot; ) ;&lt;br&gt; else&lt;br&gt; {&lt;br&gt; p -&amp;gt; top++ ;&lt;br&gt; strcpy ( p -&amp;gt; stack[p -&amp;gt; top], str ) ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* pops an expr. from the stack */&lt;br&gt; void pop ( struct postfix *p, char *a )&lt;br&gt; {&lt;br&gt; if ( p -&amp;gt; top == -1 )&lt;br&gt; printf ( &amp;quot;\nStack is empty.&amp;quot; ) ;&lt;br&gt; else&lt;br&gt; {&lt;br&gt; strcpy ( a, p -&amp;gt; stack[p -&amp;gt; top] ) ;&lt;br&gt; p -&amp;gt; top-- ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* converts given expr. to infix form */&lt;br&gt; void convert ( struct postfix *p )&lt;br&gt; {&lt;br&gt; while ( p -&amp;gt; target[p -&amp;gt; i] )&lt;br&gt; {&lt;br&gt; /* skip whitespace, if any */&lt;br&gt; if( p -&amp;gt; target[p -&amp;gt; i] == &#39; &#39; )&lt;br&gt; p -&amp;gt; i++ ;&lt;br&gt; if ( p -&amp;gt; target[p -&amp;gt; i] == &#39;%&#39; || p -&amp;gt; target[p -&amp;gt; i] == &#39;*&#39; || p -&amp;gt; target[p -&amp;gt; i] == &#39;-&#39; || p -&amp;gt; target[p -&amp;gt; i] == &#39;+&#39; || p -&amp;gt; target[p -&amp;gt; i] == &#39;/&#39; || p -&amp;gt; target[p -&amp;gt; i] == &#39;$&#39; )&lt;br&gt; {&lt;br&gt; pop ( p, p -&amp;gt; str2 ) ;&lt;br&gt; pop ( p, p -&amp;gt; str3 ) ;&lt;br&gt; p -&amp;gt; temp1[0] = p -&amp;gt; target[p -&amp;gt; i] ;&lt;br&gt; p -&amp;gt; temp1[1] = &#39;\0&#39; ;&lt;br&gt; strcpy ( p -&amp;gt; str1, p -&amp;gt; str3 ) ;&lt;br&gt; strcat ( p -&amp;gt; str1, p -&amp;gt; temp1 ) ;&lt;br&gt; strcat ( p -&amp;gt; str1, p -&amp;gt; str2 ) ;&lt;br&gt; push ( p, p -&amp;gt; str1 ) ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; p -&amp;gt; temp1[0] = p -&amp;gt; target[p -&amp;gt; i] ;&lt;br&gt; p -&amp;gt; temp1[1] = &#39;\0&#39; ;&lt;br&gt; strcpy ( p -&amp;gt; temp2, p -&amp;gt; temp1 ) ;&lt;br&gt; push ( p, p -&amp;gt; temp2 ) ;&lt;br&gt; }&lt;br&gt; p -&amp;gt; i++ ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* displays the expression */&lt;br&gt; void show ( struct postfix p )&lt;br&gt; {&lt;br&gt; char *t ;&lt;br&gt; t = p.stack[0] ;&lt;br&gt; while ( *t )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;%c &amp;quot;, *t ) ;&lt;br&gt; t++ ;&lt;br&gt; }&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/9223123628334895681'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/9223123628334895681'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-convert_18.html' title='DataStructure Program to convert an expression in postfix form to an infix form'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-5167826293515408821</id><published>2011-02-18T12:50:00.003+05:30</published><updated>2011-02-18T12:59:57.412+05:30</updated><title type='text'>DataStructure Program to compare two linked lists using recursion</title><content type='html'>&lt;div class=Section1&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; #include &amp;lt;alloc.h&amp;gt;&lt;br&gt; struct node&lt;br&gt; {&lt;br&gt; int &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_compare_two_linked_lists_using_recursion.html&quot; id=KonaLink1 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;data&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; ;&lt;br&gt; struct node *link ;&lt;br&gt; } ;&lt;br&gt; void append ( struct node **, int ) ;&lt;br&gt; int compare ( struct node *, struct node * ) ;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; struct node *first, *second ;&lt;br&gt; first = second = &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_compare_two_linked_lists_using_recursion.html&quot; id=KonaLink2 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; ; /* empty linked lists */&lt;br&gt; append ( &amp;amp;first, 1 ) ;&lt;br&gt; append ( &amp;amp;first, 2 ) ;&lt;br&gt; append ( &amp;amp;first, 3 ) ;&lt;br&gt; append ( &amp;amp;second, 1 ) ;&lt;br&gt; append ( &amp;amp;second, 2 ) ;&lt;br&gt; append ( &amp;amp;second, 3 ) ;&lt;br&gt; clrscr( ) ;&lt;br&gt; if ( compare ( first, second ) )&lt;br&gt; printf ( &amp;quot;Both linked lists are EQUAL&amp;quot; ) ;&lt;br&gt; &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_compare_two_linked_lists_using_recursion.html&quot; id=KonaLink3 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;br&gt; printf ( &amp;quot;Linked lists are DIFFERENT&amp;quot; ) ;&lt;br&gt; }&lt;br&gt; /* adds a node at the end of a linked list */&lt;br&gt; void append ( struct node **q, int num )&lt;br&gt; {&lt;br&gt; struct node *temp ;&lt;br&gt; temp = *q ;&lt;br&gt; if ( *q == NULL ) /* if the list is empty, create first node */&lt;br&gt; {&lt;br&gt; *q = malloc ( sizeof ( struct node ) ) ;&lt;br&gt; temp = *q ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; /* go to last node */&lt;br&gt; while ( temp -&amp;gt; link != NULL )&lt;br&gt; temp = temp -&amp;gt; link ;&lt;br&gt; /* add node at the end */&lt;br&gt; temp -&amp;gt; link = malloc ( sizeof ( struct node ) ) ;&lt;br&gt; temp = temp -&amp;gt; link ;&lt;br&gt; }&lt;br&gt; /* assign data to the last node */&lt;br&gt; temp -&amp;gt; data = num ;&lt;br&gt; temp -&amp;gt; link = NULL ;&lt;br&gt; }&lt;br&gt; /* compares 2 linked lists and returns 1 if linked lists are equal and 0 if unequal */&lt;br&gt; int compare ( struct node *q, struct node *r )&lt;br&gt; {&lt;br&gt; static int flag ;&lt;br&gt; if ( ( q == NULL ) &amp;amp;&amp;amp; ( r == NULL ) )&lt;br&gt; flag = 1 ;&lt;br&gt; else&lt;br&gt; {&lt;br&gt; if ( q == NULL || r == NULL )&lt;br&gt; flag = 0 ;&lt;br&gt; if ( q -&amp;gt; data != r -&amp;gt; data )&lt;br&gt; flag = 0 ;&lt;br&gt; else&lt;br&gt; compare ( q -&amp;gt; link, r -&amp;gt; link ) ;&lt;br&gt; }&lt;br&gt; return ( flag ) ;&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/5167826293515408821'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/5167826293515408821'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-compare-two.html' title='DataStructure Program to compare two linked lists using recursion'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-8428888715815433842</id><published>2011-02-18T12:50:00.002+05:30</published><updated>2011-02-18T12:59:57.175+05:30</updated><title type='text'>DataStructure Program for Quick sort</title><content type='html'>&lt;div class=Section1&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; int split ( int*, int, int ) ;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; int arr[10] = { 11, 2, 9, 13, 57, 25, 17, 1, 90, 3 } ;&lt;br&gt; int i ;&lt;br&gt; void quicksort ( int *, int, int ) ;&lt;br&gt; clrscr( ) ;&lt;br&gt; printf ( &amp;quot;Quick sort.\n&amp;quot; ) ;&lt;br&gt; printf ( &amp;quot;\nArray before sorting:\n&amp;quot;) ;&lt;br&gt; for ( i = 0 ; i &amp;lt;= 9 ; i++ )&lt;br&gt; printf ( &amp;quot;%d\t&amp;quot;, arr[i] ) ;&lt;br&gt; quicksort ( arr, 0, 9 ) ;&lt;br&gt; printf ( &amp;quot;\nArray after sorting:\n&amp;quot;) ;&lt;br&gt; for ( i = 0 ; i &amp;lt;= 9 ; i++ )&lt;br&gt; printf ( &amp;quot;%d\t&amp;quot;, arr[i] ) ;&lt;br&gt; getch( ) ;&lt;br&gt; }&lt;br&gt; void quicksort ( int a[ ], int lower, int upper )&lt;br&gt; {&lt;br&gt; int i ;&lt;br&gt; if ( upper &amp;gt; lower )&lt;br&gt; {&lt;br&gt; i = split ( a, lower, upper ) ;&lt;br&gt; quicksort ( a, lower, i - 1 ) ;&lt;br&gt; quicksort ( a, i + 1, upper ) ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; int split ( int a[ ], int lower, int upper )&lt;br&gt; {&lt;br&gt; int i, p, q, t ;&lt;br&gt; p = lower + 1 ;&lt;br&gt; q = upper ;&lt;br&gt; i = a[lower] ;&lt;br&gt; while ( q &amp;gt;= p )&lt;br&gt; {&lt;br&gt; while ( a[p] &amp;lt; i )&lt;br&gt; p++ ;&lt;br&gt; while ( a[q] &amp;gt; i )&lt;br&gt; q-- ;&lt;br&gt; if ( q &amp;gt; p )&lt;br&gt; {&lt;br&gt; t = a[p] ;&lt;br&gt; a[p] = a[q] ;&lt;br&gt; a[q] = t ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; t = a[lower] ;&lt;br&gt; a[lower] = a[q] ;&lt;br&gt; a[q] = t ;&lt;br&gt; return q ;&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/8428888715815433842'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/8428888715815433842'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-for-quick-sort.html' title='DataStructure Program for Quick sort'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-3124382232315553593</id><published>2011-02-18T12:50:00.001+05:30</published><updated>2011-02-18T12:51:31.229+05:30</updated><title type='text'>DataStructure Program for Merge Sort</title><content type='html'>&lt;div class=Section1&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; int a[5] = { 11, 2, 9, 13, 57 } ;&lt;br&gt; int b[5] = { 25, 17, 1, 90, 3 } ;&lt;br&gt; int c[10] ;&lt;br&gt; int i, j, k, temp ;&lt;br&gt; clrscr( ) ;&lt;br&gt; printf ( &amp;quot;Merge sort.\n&amp;quot; ) ;&lt;br&gt; printf ( &amp;quot;\nFirst array:\n&amp;quot; ) ;&lt;br&gt; for ( i = 0 ; i &amp;lt;= 4 ; i++ )&lt;br&gt; printf ( &amp;quot;%d\t&amp;quot;, a[i] ) ;&lt;br&gt; printf ( &amp;quot;\n\nSecond array:\n&amp;quot; ) ;&lt;br&gt; for ( i = 0 ; i &amp;lt;= 4 ; i++ )&lt;br&gt; printf ( &amp;quot;%d\t&amp;quot;, b[i] ) ;&lt;br&gt; for ( i = 0 ; i &amp;lt;= 3 ; i++ )&lt;br&gt; {&lt;br&gt; for ( j = i + 1 ; j &amp;lt;= 4 ; j++ )&lt;br&gt; {&lt;br&gt; if ( a[i] &amp;gt; a[j] )&lt;br&gt; {&lt;br&gt; temp = a[i] ;&lt;br&gt; a[i] = a[j] ;&lt;br&gt; a[j] = temp ;&lt;br&gt; }&lt;br&gt; if ( b[i] &amp;gt; b[j] )&lt;br&gt; {&lt;br&gt; temp = b[i] ;&lt;br&gt; b[i] = b[j] ;&lt;br&gt; b[j] = temp ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; }&lt;br&gt; for ( i = j = k = 0 ; i &amp;lt;= 9 ; )&lt;br&gt; {&lt;br&gt; if ( a[j] &amp;lt;= b[k] )&lt;br&gt; c[i++] = a[j++] ;&lt;br&gt; else&lt;br&gt; c[i++] = b[k++] ;&lt;br&gt; if ( j == 5 || k == 5 )&lt;br&gt; break ;&lt;br&gt; }&lt;br&gt; for ( ; j &amp;lt;= 4 ; )&lt;br&gt; c[i++] = a[j++] ;&lt;br&gt; for ( ; k &amp;lt;= 4 ; )&lt;br&gt; c[i++] = b[k++] ;&lt;br&gt; printf ( &amp;quot;\n\nArray after sorting:\n&amp;quot;) ;&lt;br&gt; for ( i = 0 ; i &amp;lt;= 9 ; i++ )&lt;br&gt; printf ( &amp;quot;%d\t&amp;quot;, c[i] ) ;&lt;br&gt; getch( ) ;&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/3124382232315553593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/3124382232315553593'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-for-merge-sort.html' title='DataStructure Program for Merge Sort'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-3031863795736206826</id><published>2011-02-18T12:50:00.000+05:30</published><updated>2011-02-18T12:49:37.881+05:30</updated><title type='text'>DataStructure Program to check for the entered name in the master list</title><content type='html'>&lt;div class=Section1&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; #include &amp;lt;string.h&amp;gt;&lt;br&gt; #define MAX1 6&lt;br&gt; #define MAX2 10&lt;br&gt; char masterlist[MAX1][MAX2] ;&lt;br&gt; int count ;&lt;br&gt; int add ( char *s ) ;&lt;br&gt; int find ( char *s ) ;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; char yourname[MAX2] ;&lt;br&gt; int &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_check_entered_name_in_master_list.html&quot; id=KonaLink0 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;flag&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; ;&lt;br&gt; clrscr( ) ;&lt;br&gt; flag = add ( &amp;quot;akshay&amp;quot; ) ;&lt;br&gt; if ( flag == 0 )&lt;br&gt; printf ( &amp;quot;\nUnable to add string&amp;quot; ) ;&lt;br&gt; flag = add ( &amp;quot;parag&amp;quot; ) ;&lt;br&gt; if ( flag == 0 )&lt;br&gt; printf ( &amp;quot;\nUnable to add string&amp;quot; ) ;&lt;br&gt; flag = add ( &amp;quot;raman&amp;quot; ) ;&lt;br&gt; if ( flag == 0 )&lt;br&gt; printf ( &amp;quot;\nUnable to add string&amp;quot; ) ;&lt;br&gt; flag = add ( &amp;quot;srinivas&amp;quot; ) ;&lt;br&gt; if ( flag == 0 )&lt;br&gt; printf ( &amp;quot;\nUnable to add string&amp;quot; ) ;&lt;br&gt; flag = add ( &amp;quot;gopal&amp;quot; ) ;&lt;br&gt; if ( flag == 0 )&lt;br&gt; printf ( &amp;quot;\nUnable to add string&amp;quot; ) ;&lt;br&gt; flag = add ( &amp;quot;rajesh&amp;quot; ) ;&lt;br&gt; if ( flag == 0 )&lt;br&gt; printf ( &amp;quot;Unable to add string&amp;quot; ) ;&lt;br&gt; printf ( &amp;quot;Enter your name: &amp;quot; ) ;&lt;br&gt; gets ( yourname ) ;&lt;br&gt; flag = find ( yourname ) ;&lt;br&gt; if ( flag == 1 )&lt;br&gt; printf ( &amp;quot;Welcome, you can enter the palace\n&amp;quot; ) ;&lt;br&gt; else&lt;br&gt; printf ( &amp;quot;Sorry, you are a trespasser&amp;quot; ) ;&lt;br&gt; getch( ) ;&lt;br&gt; }&lt;br&gt; /* adds string to the array */&lt;br&gt; int add ( char *s )&lt;br&gt; {&lt;br&gt; if ( count &amp;lt; MAX1 )&lt;br&gt; {&lt;br&gt; if ( strlen ( s ) &amp;lt; MAX2 )&lt;br&gt; {&lt;br&gt; strcpy ( &amp;amp;masterlist[count][0], s ) ;&lt;br&gt; count++ ;&lt;br&gt; return 1 ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; return 0 ;&lt;br&gt; }&lt;br&gt; /* finds the given string */&lt;br&gt; int find ( char *s )&lt;br&gt; {&lt;br&gt; int flag = 0, i ;&lt;br&gt; for ( i = 0 ; i &amp;lt; count ; i++ )&lt;br&gt; {&lt;br&gt; if ( strcmp ( &amp;amp;masterlist[i][0], s ) == 0 )&lt;br&gt; {&lt;br&gt; flag = 1 ;&lt;br&gt; break ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; return flag ;&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/3031863795736206826'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/3031863795736206826'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-check-for.html' title='DataStructure Program to check for the entered name in the master list'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-503005075326649632</id><published>2011-02-18T12:49:00.009+05:30</published><updated>2011-02-18T12:49:36.717+05:30</updated><title type='text'>DataStructure Program to build a binary search tree from arrays</title><content type='html'>&lt;div class=Section1&gt;    &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span  style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt;  #include &amp;lt;conio.h&amp;gt;&lt;br&gt;  #include &amp;lt;alloc.h&amp;gt;&lt;br&gt;  struct node&lt;br&gt;  {&lt;br&gt;  struct node *left ;&lt;br&gt;  &lt;a  href=&quot;http://www.technicalsymposium.com/Program_to_build_a_binary_search_tree_from_arrays.html&quot;  id=KonaLink1 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span  class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important;  font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important;  font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;char&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;  data ;&lt;br&gt;  struct node *right ;&lt;br&gt;  } ;&lt;br&gt;  struct node * buildtree ( int ) ;&lt;br&gt;  void inorder ( struct node * ) ;&lt;br&gt;  char arr[ ] = { &#39;A&#39;, &#39;B&#39;, &#39;C&#39;, &#39;D&#39;, &#39;E&#39;, &#39;F&#39;, &#39;G&#39;, &#39;\0&#39;, &#39;\0&#39;, &#39;H&#39; } ;&lt;br&gt;  int lc[ ] = { 1, 3, 5, -1, 9, -1, -1, -1, -1, -1 } ;&lt;br&gt;  int rc[ ] = { 2, 4, 6, -1, -1, -1, -1, -1, -1, -1 } ;&lt;br&gt;  void main( )&lt;br&gt;  {&lt;br&gt;  struct node *root ;&lt;br&gt;  clrscr( ) ;&lt;br&gt;  root = buildtree ( 0 ) ;&lt;br&gt;  printf ( &lt;/span&gt;&lt;/font&gt;&lt;font color=white face=Tahoma&gt;&lt;span style=&#39;font-family:  Tahoma;color:white&#39;&gt;�&lt;/span&gt;&lt;/font&gt;&lt;font color=white&gt;&lt;span style=&#39;color:white&#39;&gt;In-order  Traversal:\n&lt;/span&gt;&lt;/font&gt;&lt;font color=white face=Tahoma&gt;&lt;span style=&#39;font-family:  Tahoma;color:white&#39;&gt;�&lt;/span&gt;&lt;/font&gt;&lt;font color=white&gt;&lt;span style=&#39;color:white&#39;&gt;  ) ;&lt;br&gt;  inorder ( root ) ;&lt;br&gt;  getch( ) ;&lt;br&gt;  }&lt;br&gt;  struct node * buildtree ( int index )&lt;br&gt;  {&lt;br&gt;  struct node *temp = &lt;a  href=&quot;http://www.technicalsymposium.com/Program_to_build_a_binary_search_tree_from_arrays.html&quot;  id=KonaLink2 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span  class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important;  font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important;  font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;  ;&lt;br&gt;  if ( index != -1 )&lt;br&gt;  {&lt;br&gt;  temp = ( struct node * ) malloc ( sizeof ( struct node ) ) ;&lt;br&gt;  temp -&amp;gt; left = buildtree ( lc[index] ) ;&lt;br&gt;  temp -&amp;gt; data = arr[index] ;&lt;br&gt;  temp -&amp;gt; right = buildtree ( rc[index] ) ;&lt;br&gt;  }&lt;br&gt;  return temp ;&lt;br&gt;  }&lt;br&gt;  void inorder ( struct node *root )&lt;br&gt;  {&lt;br&gt;  if ( root != NULL )&lt;br&gt;  {&lt;br&gt;  inorder ( root -&amp;gt; left ) ;&lt;br&gt;  printf ( &amp;quot;%c\t&amp;quot;, root -&amp;gt; data ) ;&lt;br&gt;  inorder ( root -&amp;gt; right ) ;&lt;br&gt;  }&lt;br&gt;  }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt;  font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;    &lt;/div&gt;    </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/503005075326649632'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/503005075326649632'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-build-binary.html' title='DataStructure Program to build a binary search tree from arrays'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-8152081761478671773</id><published>2011-02-18T12:49:00.007+05:30</published><updated>2011-02-18T12:49:34.615+05:30</updated><title type='text'>DataStructure Program to allocate memory dynamically</title><content type='html'>&lt;div class=Section1&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; #include &amp;lt;alloc.h&amp;gt;&lt;br&gt; #include &amp;lt;string.h&amp;gt;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; char *name[5] ;&lt;br&gt; char str[20] ;&lt;br&gt; int i ;&lt;br&gt; clrscr( ) ;&lt;br&gt; for ( i = 0 ; i &amp;lt; 5 ; i++ )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;Enter a String: &amp;quot; ) ;&lt;br&gt; gets ( str ) ;&lt;br&gt; name[i] = ( char * ) malloc ( strlen ( str ) + 1 ) ;&lt;br&gt; strcpy ( name[i], str ) ;&lt;br&gt; }&lt;br&gt; printf ( &amp;quot;\nThe strings are:&amp;quot; ) ;&lt;br&gt; for ( i = 0 ; i &amp;lt; 5 ; i++ )&lt;br&gt; printf ( &amp;quot;\n%s&amp;quot;, name[i] ) ;&lt;br&gt; for ( i = 0 ; i &amp;lt; 5 ; i++ )&lt;br&gt; free ( name[i] ) ;&lt;br&gt; getch( ) ;&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/8152081761478671773'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/8152081761478671773'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-allocate.html' title='DataStructure Program to allocate memory dynamically'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-436086633872465141</id><published>2011-02-18T12:49:00.005+05:30</published><updated>2011-02-18T12:49:32.952+05:30</updated><title type='text'>DataStructure Program to add two sparse matrices</title><content type='html'>&lt;div class=Section1&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; #include &amp;lt;alloc.h&amp;gt;&lt;br&gt; #define MAX1 3&lt;br&gt; #define MAX2 3&lt;br&gt; #define MAXSIZE 9&lt;br&gt; #define BIGNUM 100&lt;br&gt; struct sparse&lt;br&gt; {&lt;br&gt; int *sp ;&lt;br&gt; int row ;&lt;br&gt; int *result ;&lt;br&gt; } ;&lt;br&gt; void initsparse ( struct sparse * ) ;&lt;br&gt; void create_array ( struct sparse * ) ;&lt;br&gt; int count ( struct sparse ) ;&lt;br&gt; void display ( struct sparse ) ;&lt;br&gt; void create_tuple ( struct sparse *, struct sparse ) ;&lt;br&gt; void display_tuple ( struct sparse ) ;&lt;br&gt; void addmat ( struct sparse *, struct sparse, struct sparse ) ;&lt;br&gt; void display_result ( struct sparse ) ;&lt;br&gt; void delsparse ( struct sparse * ) ;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; struct sparse s[5] ;&lt;br&gt; int i ;&lt;br&gt; clrscr( ) ;&lt;br&gt; for ( i = 0 ; i &amp;lt;= 4 ; i++ )&lt;br&gt; initsparse ( &amp;amp;s[i] ) ;&lt;br&gt; create_array ( &amp;amp;s[0] ) ;&lt;br&gt; create_tuple ( &amp;amp;s[1], s[0] ) ;&lt;br&gt; display_tuple ( s[1] ) ;&lt;br&gt; create_array ( &amp;amp;s[2] ) ;&lt;br&gt; create_tuple ( &amp;amp;s[3], s[2] ) ;&lt;br&gt; display_tuple ( s[3] ) ;&lt;br&gt; addmat ( &amp;amp;s[4], s[1], s[3] ) ;&lt;br&gt; printf ( &amp;quot;\nResult of addition of two matrices: &amp;quot; ) ;&lt;br&gt; display_result ( s[4] ) ;&lt;br&gt; for ( i = 0 ; i &amp;lt;= 4 ; i++ )&lt;br&gt; delsparse ( &amp;amp;s[i] ) ;&lt;br&gt; getch( ) ;&lt;br&gt; }&lt;br&gt; /* initialises structure elements */&lt;br&gt; void initsparse ( struct sparse *p )&lt;br&gt; {&lt;br&gt; p -&amp;gt; sp = NULL ;&lt;br&gt; p -&amp;gt; result = NULL ;&lt;br&gt; }&lt;br&gt; /* dynamically creates the matrix */&lt;br&gt; void create_array ( struct sparse *p )&lt;br&gt; {&lt;br&gt; int n, i ;&lt;br&gt; /* allocate memory */&lt;br&gt; p -&amp;gt; sp = ( int * ) malloc ( MAX1 * MAX2 * sizeof ( int ) ) ;&lt;br&gt; /* add elements to the array */&lt;br&gt; for ( i = 0 ; i &amp;lt; MAX1 * MAX2 ; i++ )&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;Enter element no. %d:&amp;quot;, i ) ;&lt;br&gt; scanf ( &amp;quot;%d&amp;quot;, &amp;amp;n ) ;&lt;br&gt; * ( p -&amp;gt; sp + i ) = n ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* displays the contents of the matrix */&lt;br&gt; void display ( struct sparse s )&lt;br&gt; {&lt;br&gt; int i ;&lt;br&gt; /* traverses the entire matrix */&lt;br&gt; for ( i = 0 ; i &amp;lt; MAX1 * MAX2 ; i++ )&lt;br&gt; {&lt;br&gt; /* positions the &lt;a href=&quot;http://www.technicalsymposium.com/Program_to_add_two_sparse_matrices.html&quot; id=KonaLink0 style=&#39;font-weight:inherit ! important;font-size:inherit ! important&#39;&gt;&lt;span class=klink&gt;&lt;font color=white style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;font-weight:inherit ! important; font-size:inherit ! important&#39;&gt;&lt;span style=&#39;color:white&#39;&gt;cursor&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt; to the new line for every new row */&lt;br&gt; if ( i % MAX2 == 0 )&lt;br&gt; printf ( &amp;quot;\n&amp;quot; ) ;&lt;br&gt; printf ( &amp;quot;%d\t&amp;quot;, * ( s.sp + i ) ) ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* counts the number of non-zero elements */&lt;br&gt; int count ( struct sparse s )&lt;br&gt; {&lt;br&gt; int cnt = 0, i ;&lt;br&gt; for ( i = 0 ; i &amp;lt; MAX1 * MAX2 ; i++ )&lt;br&gt; {&lt;br&gt; if ( * ( s.sp + i ) != 0 )&lt;br&gt; cnt++ ;&lt;br&gt; }&lt;br&gt; return cnt ;&lt;br&gt; }&lt;br&gt; /* creates an array that stores information about non-zero elements */&lt;br&gt; void create_tuple ( struct sparse *p, struct sparse s )&lt;br&gt; {&lt;br&gt; int r = 0 , c = -1, l = -1, i ;&lt;br&gt; /* get the total number of non-zero elements&lt;br&gt; and add 1 to store total no. of rows, cols, and non-zero values */&lt;br&gt; p -&amp;gt; row = count ( s ) + 1 ;&lt;br&gt; /* allocate memory */&lt;br&gt; p -&amp;gt; sp = ( int * ) malloc ( p -&amp;gt; row * 3 * sizeof ( int ) ) ;&lt;br&gt; /* store information about&lt;br&gt; total no. of rows, cols, and non-zero values */&lt;br&gt; * ( p -&amp;gt; sp + 0 ) = MAX1 ;&lt;br&gt; * ( p -&amp;gt; sp + 1 ) = MAX2 ;&lt;br&gt; * ( p -&amp;gt; sp + 2 ) = p -&amp;gt; row - 1 ;&lt;br&gt; l = 2 ;&lt;br&gt; /* scan the array and store info. about non-zero values in the 3-tuple */&lt;br&gt; for ( i = 0 ; i &amp;lt; MAX1 * MAX2 ; i++ )&lt;br&gt; {&lt;br&gt; c++ ;&lt;br&gt; /* sets the row and column values */&lt;br&gt; if ( ( ( i % MAX2 ) == 0 ) &amp;amp;&amp;amp; ( i != 0 ) )&lt;br&gt; {&lt;br&gt; r++ ;&lt;br&gt; c = 0 ;&lt;br&gt; }&lt;br&gt; /* checks for non-zero element row, column and non-zero element value is assigned to the matrix */&lt;br&gt; if ( * ( s.sp + i ) != 0 )&lt;br&gt; {&lt;br&gt; l++ ;&lt;br&gt; * ( p -&amp;gt; sp + l ) = r ;&lt;br&gt; l++ ;&lt;br&gt; * ( p -&amp;gt; sp + l ) = c ;&lt;br&gt; l++ ;&lt;br&gt; * ( p -&amp;gt; sp + l ) = * ( s.sp + i ) ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* displays the contents of the matrix */&lt;br&gt; void display_tuple ( struct sparse s )&lt;br&gt; {&lt;br&gt; int i, j ;&lt;br&gt; /* traverses the entire matrix */&lt;br&gt; printf ( &amp;quot;\nElements in a 3-tuple: \n&amp;quot; ) ;&lt;br&gt; j = ( * ( s.sp + 2 ) * 3 ) + 3 ;&lt;br&gt; for ( i = 0 ; i &amp;lt; j ; i++ )&lt;br&gt; {&lt;br&gt; /* positions the cursor to the new line for every new row */&lt;br&gt; if ( i % 3 == 0 )&lt;br&gt; printf ( &amp;quot;\n&amp;quot; ) ;&lt;br&gt; printf ( &amp;quot;%d\t&amp;quot;, * ( s.sp + i ) ) ;&lt;br&gt; }&lt;br&gt; printf ( &amp;quot;\n&amp;quot; ) ;&lt;br&gt; }&lt;br&gt; /* carries out addition of two matrices */&lt;br&gt; void addmat ( struct sparse *p, struct sparse s1, struct sparse s2 )&lt;br&gt; {&lt;br&gt; int i = 1, j = 1, k = 1 ;&lt;br&gt; int elem = 1 ;&lt;br&gt; int max, amax, bmax ;&lt;br&gt; int rowa, rowb, cola, colb, vala, valb ;&lt;br&gt; /* get the total number of non-zero values from both the matrices */&lt;br&gt; amax = * ( s1.sp + 2 ) ;&lt;br&gt; bmax = * ( s2.sp + 2 ) ;&lt;br&gt; max = amax + bmax ;&lt;br&gt; /* allocate memory for result */&lt;br&gt; p -&amp;gt; result = ( int * ) malloc ( MAXSIZE * 3 * sizeof ( int ) ) ;&lt;br&gt; while ( elem &amp;lt;= max )&lt;br&gt; {&lt;br&gt; /* check if i &amp;lt; max. non-zero values&lt;br&gt; in first 3-tuple and get the values */&lt;br&gt; if ( i &amp;lt;= amax )&lt;br&gt; {&lt;br&gt; rowa = * ( s1.sp + i * 3 + 0 ) ;&lt;br&gt; cola = * ( s1.sp + i * 3 + 1 ) ;&lt;br&gt; vala = * ( s1.sp + i * 3 + 2 ) ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; rowa = cola = BIGNUM ; &lt;br&gt; /* check if j &amp;lt; max. non-zero values in secon 3-tuple and get the values */&lt;br&gt; if ( j &amp;lt;= bmax )&lt;br&gt; {&lt;br&gt; rowb = * ( s2.sp + j * 3 + 0 ) ;&lt;br&gt; colb = * ( s2.sp + j * 3 + 1 ) ;&lt;br&gt; valb = * ( s2.sp + j * 3 + 2 ) ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; rowb = colb = BIGNUM ;&lt;br&gt; /* if row no. of both 3-tuple are same */&lt;br&gt; if ( rowa == rowb )&lt;br&gt; {&lt;br&gt; /* if col no. of both 3-tuple are same */&lt;br&gt; if ( cola == colb )&lt;br&gt; {&lt;br&gt; /* add tow non-zero values&lt;br&gt; store in result */&lt;br&gt; * ( p -&amp;gt; result + k * 3 + 0 ) = rowa ;&lt;br&gt; * ( p -&amp;gt; result + k * 3 + 1 ) = cola ;&lt;br&gt; * ( p -&amp;gt; result + k * 3 + 2 ) = vala + valb ;&lt;br&gt; i++ ;&lt;br&gt; j++ ;&lt;br&gt; max-- ;&lt;br&gt; }&lt;br&gt; /* if col no. of first 3-tuple is &amp;lt; col no. of second 3-tuple, then add info. as it is to result */&lt;br&gt; if ( cola &amp;lt; colb )&lt;br&gt; {&lt;br&gt; * ( p -&amp;gt; result + k * 3 + 0 ) = rowa ;&lt;br&gt; * ( p -&amp;gt; result + k * 3 + 1 ) = cola ;&lt;br&gt; * ( p -&amp;gt; result + k * 3 + 2 ) = vala ;&lt;br&gt; i++ ;&lt;br&gt; }&lt;br&gt; /* if col no. of first 3-tuple is &amp;gt; col no. of second 3-tuple, then add info. as it is to result */&lt;br&gt; if ( cola &amp;gt; colb )&lt;br&gt; {&lt;br&gt; * ( p -&amp;gt; result + k * 3 + 0 ) = rowb ;&lt;br&gt; * ( p -&amp;gt; result + k * 3 + 1 ) = colb ;&lt;br&gt; * ( p -&amp;gt; result + k * 3 + 2 ) = valb ;&lt;br&gt; j++ ;&lt;br&gt; }&lt;br&gt; k++ ;&lt;br&gt; }&lt;br&gt; /* if row no. of first 3-tuple is &amp;lt; row no. of second 3-tuple, then add info. as it is to result */&lt;br&gt; if ( rowa &amp;lt; rowb )&lt;br&gt; {&lt;br&gt; * ( p -&amp;gt; result + k * 3 + 0 ) = rowa ;&lt;br&gt; * ( p -&amp;gt; result + k * 3 + 1 ) = cola ;&lt;br&gt; * ( p -&amp;gt; result + k * 3 + 2 ) = vala ;&lt;br&gt; i++ ;&lt;br&gt; k++ ;&lt;br&gt; }&lt;br&gt; /* if row no. of first 3-tuple is &amp;gt; row no. of second 3-tuple, then add info. as it is to result */&lt;br&gt; if ( rowa &amp;gt; rowb )&lt;br&gt; {&lt;br&gt; * ( p -&amp;gt; result + k * 3 + 0 ) = rowb ;&lt;br&gt; * ( p -&amp;gt; result + k * 3 + 1 ) = colb ;&lt;br&gt; * ( p -&amp;gt; result + k * 3 + 2 ) = valb ;&lt;br&gt; j++ ;&lt;br&gt; k++ ;&lt;br&gt; }&lt;br&gt; elem++ ;&lt;br&gt; }&lt;br&gt; /* add info about the total no. of rows, cols, and non-zero values that the resultant array contains to the result */&lt;br&gt; * ( p -&amp;gt; result + 0 ) = MAX1 ;&lt;br&gt; * ( p -&amp;gt; result + 1 ) = MAX2 ;&lt;br&gt; * ( p -&amp;gt; result + 2 ) = max ;&lt;br&gt; }&lt;br&gt; /* displays the contents of the matrix */&lt;br&gt; void display_result ( struct sparse s )&lt;br&gt; {&lt;br&gt; int i ;&lt;br&gt; /* traverses the entire matrix */&lt;br&gt; for ( i = 0 ; i &amp;lt; ( * ( s.result + 0 + 2 ) + 1 ) * 3 ; i++ )&lt;br&gt; {&lt;br&gt; /* positions the cursor to the new line for every new row */&lt;br&gt; if ( i % 3 == 0 )&lt;br&gt; printf ( &amp;quot;\n&amp;quot; ) ;&lt;br&gt; printf ( &amp;quot;%d\t&amp;quot;, * ( s.result + i ) ) ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* deallocates memory */&lt;br&gt; void delsparse ( struct sparse *p )&lt;br&gt; {&lt;br&gt; if ( p -&amp;gt; sp != NULL )&lt;br&gt; free ( p -&amp;gt; sp ) ;&lt;br&gt; if ( p -&amp;gt; result != NULL )&lt;br&gt; free ( p -&amp;gt; result ) ;&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/436086633872465141'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/436086633872465141'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-add-two-sparse.html' title='DataStructure Program to add two sparse matrices'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry><entry><id>tag:blogger.com,1999:blog-8286439525414307195.post-3499488392666531030</id><published>2011-02-18T12:49:00.003+05:30</published><updated>2011-02-18T12:49:32.225+05:30</updated><title type='text'>DataStructure Program to add two polynomials</title><content type='html'>&lt;div class=Section1&gt;  &lt;p class=MsoNormal&gt;&lt;font size=3 color=white face=&quot;Times New Roman&quot;&gt;&lt;span style=&#39;font-size:12.0pt;color:white&#39;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br&gt; #include &amp;lt;conio.h&amp;gt;&lt;br&gt; #define MAX 10&lt;br&gt; struct term&lt;br&gt; {&lt;br&gt; int coeff ;&lt;br&gt; int exp ;&lt;br&gt; } ;&lt;br&gt; struct poly&lt;br&gt; {&lt;br&gt; struct term t [10] ;&lt;br&gt; int noofterms ;&lt;br&gt; } ;&lt;br&gt; void initpoly ( struct poly * ) ;&lt;br&gt; void polyappend ( struct poly *, int c, int e ) ;&lt;br&gt; struct poly polyadd ( struct poly, struct poly ) ;&lt;br&gt; void display ( struct poly ) ;&lt;br&gt; void main( )&lt;br&gt; {&lt;br&gt; struct poly p1, p2, p3 ;&lt;br&gt; clrscr( ) ;&lt;br&gt; initpoly ( &amp;amp;p1 ) ;&lt;br&gt; initpoly ( &amp;amp;p2 ) ;&lt;br&gt; initpoly ( &amp;amp;p3 ) ;&lt;br&gt; polyappend ( &amp;amp;p1, 1, 7 ) ;&lt;br&gt; polyappend ( &amp;amp;p1, 2, 6 ) ;&lt;br&gt; polyappend ( &amp;amp;p1, 3, 5 ) ;&lt;br&gt; polyappend ( &amp;amp;p1, 4, 4 ) ;&lt;br&gt; polyappend ( &amp;amp;p1, 5, 2 ) ;&lt;br&gt; polyappend ( &amp;amp;p2, 1, 4 ) ;&lt;br&gt; polyappend ( &amp;amp;p2, 1, 3 ) ;&lt;br&gt; polyappend ( &amp;amp;p2, 1, 2 ) ;&lt;br&gt; polyappend ( &amp;amp;p2, 1, 1 ) ;&lt;br&gt; polyappend ( &amp;amp;p2, 2, 0 ) ;&lt;br&gt; p3 = polyadd ( p1, p2 ) ;&lt;br&gt; printf ( &amp;quot;\nFirst polynomial:\n&amp;quot; ) ;&lt;br&gt; display ( p1 ) ;&lt;br&gt; printf ( &amp;quot;\n\nSecond polynomial:\n&amp;quot; ) ;&lt;br&gt; display ( p2 ) ;&lt;br&gt; printf ( &amp;quot;\n\nResultant polynomial:\n&amp;quot; ) ;&lt;br&gt; display ( p3 ) ;&lt;br&gt; getch( ) ;&lt;br&gt; }&lt;br&gt; /* initializes elements of struct poly */&lt;br&gt; void initpoly ( struct poly *p )&lt;br&gt; {&lt;br&gt; int i ;&lt;br&gt; p -&amp;gt; noofterms = 0 ;&lt;br&gt; for ( i = 0 ; i &amp;lt; MAX ; i++ )&lt;br&gt; {&lt;br&gt; p -&amp;gt; t[i].coeff = 0 ;&lt;br&gt; p -&amp;gt; t[i].exp = 0 ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; /* adds the term of polynomial to the array t */&lt;br&gt; void polyappend ( struct poly *p, int c, int e )&lt;br&gt; {&lt;br&gt; p -&amp;gt; t[p -&amp;gt; noofterms].coeff = c ;&lt;br&gt; p -&amp;gt; t[p -&amp;gt; noofterms].exp = e ;&lt;br&gt; ( p -&amp;gt; noofterms ) ++ ;&lt;br&gt; }&lt;br&gt; /* displays the polynomial equation */&lt;br&gt; void display ( struct poly p )&lt;br&gt; {&lt;br&gt; int flag = 0, i ;&lt;br&gt; for ( i = 0 ; i &amp;lt; p.noofterms ; i++ )&lt;br&gt; {&lt;br&gt; if ( p.t[i].exp != 0 )&lt;br&gt; printf ( &amp;quot;%d x^%d + &amp;quot;, p.t[i].coeff, p.t[i].exp ) ;&lt;br&gt; else&lt;br&gt; {&lt;br&gt; printf ( &amp;quot;%d&amp;quot;, p.t[i].coeff ) ;&lt;br&gt; flag = 1 ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; if ( !flag )&lt;br&gt; printf ( &amp;quot;\b\b &amp;quot; ) ;&lt;br&gt; }&lt;br&gt; /* adds two polynomials p1 and p2 */&lt;br&gt; struct poly polyadd ( struct poly p1, struct poly p2 )&lt;br&gt; {&lt;br&gt; int i, j, c ;&lt;br&gt; struct poly p3 ;&lt;br&gt; initpoly ( &amp;amp;p3 ) ;&lt;br&gt; if ( p1.noofterms &amp;gt; p2.noofterms )&lt;br&gt; c = p1.noofterms ;&lt;br&gt; else&lt;br&gt; c = p2.noofterms ;&lt;br&gt; for ( i = 0, j = 0 ; i &amp;lt;= c ; p3.noofterms++ )&lt;br&gt; {&lt;br&gt; if ( p1.t[i].coeff == 0 &amp;amp;&amp;amp; p2.t[j].coeff == 0 )&lt;br&gt; break ;&lt;br&gt; if ( p1.t[i].exp &amp;gt;= p2.t[j].exp )&lt;br&gt; {&lt;br&gt; if ( p1.t[i].exp == p2.t[j].exp )&lt;br&gt; {&lt;br&gt; p3.t[p3.noofterms].coeff = p1.t[i].coeff + p2.t[j].coeff ;&lt;br&gt; p3.t[p3.noofterms].exp = p1.t[i].exp ;&lt;br&gt; i++ ;&lt;br&gt; j++ ;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; p3.t[p3.noofterms].coeff = p1.t[i].coeff ;&lt;br&gt; p3.t[p3.noofterms].exp = p1.t[i].exp ;&lt;br&gt; i++ ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; else&lt;br&gt; {&lt;br&gt; p3.t[p3.noofterms].coeff = p2.t[j].coeff ;&lt;br&gt; p3.t[p3.noofterms].exp = p2.t[j].exp ;&lt;br&gt; j++ ;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; return p3 ;&lt;br&gt; }&lt;/span&gt;&lt;/font&gt;&lt;font size=2 color=white face=Arial&gt;&lt;span style=&#39;font-size:10.0pt; font-family:Arial;color:white&#39;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/3499488392666531030'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8286439525414307195/posts/default/3499488392666531030'/><link rel='alternate' type='text/html' href='http://allaboutshimoga.blogspot.com/2011/02/datastructure-program-to-add-two_18.html' title='DataStructure Program to add two polynomials'/><author><name>nandan</name><uri>http://www.blogger.com/profile/10467951923423146009</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIMrOG6FUfb4LSAgkU-BDzRRqX3dNA8cCeH1V6p77hYyv1hxbgW8C68_LwltOOqZr9p0_bbzx2gRGyYoKmJ23Q1yifA3d1NHYprK-UKfgDTT4iJWmVD0bYog-8qQbdCis/s220/P3045641.JPG'/></author></entry></feed>