BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan Right Header

Register FAQ Community Calendar New Posts Navbar Right Corner
HOME BZU Mail Box Online Games Radio and TV Cricket All Albums
Go Back   BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan > Institute of Computing > Bachelor of Science in Computer Science > BsCS 6th Semester > Visual Programming


Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 17-06-2011, 08:58 PM
thecool's Avatar
Senior Member


 
Join Date: Apr 2009
Location: Multan
Posts: 1,163
Contact Number: Push me a PM if you really need
Program / Discipline: Alumni
Class Roll Number: ---
thecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond repute
Cool C-Sharp Program Double Linked List (All Functions In One Program)

C-Sharp Program Double Linked List (All Functions In One Program)

Code:
using System;
using System.Collections.Generic;
using System.Text;

namespace Double_Link_List
{
    class Program
    {
        static void Main(string[] args)
        {
            DoubleLinkList s = new DoubleLinkList();
            s.InsertionAtFirst(2);
            s.InsertionAtFirst(1);
            Console.WriteLine("Traversing is......................");
            s.tarvasing();
            Console.WriteLine("Now insertion at last.............");
            s.InsertionAtLast(4);
            s.InsertionAtLast(5);
            Console.WriteLine("Traversing is......................");
            s.tarvasing();
            s.IsertionAtAnyPlace(3, 2);
            s.tarvasing();
            s.deletionatfront();
            s.tarvasing();c
        }
    }
    class Node
    {
        public object data;
        public Node llink;
        public Node rlink;
    }
    class DoubleLinkList
    {
        Node header = new Node();

        public void tarvasing()
        {
            Node pr = header;
            while (pr.rlink != null)
            {
                pr = pr.rlink;
                Console.WriteLine(pr.data);

}


        }

        public void InsertionAtFirst(object item)
        {
            header.llink = null;
            Node pr = header.rlink;
            Node newnode = new Node();
            //if(newnode.rlink!=null)
            //{
            newnode.llink = header.rlink;
            header.rlink = newnode;
            newnode.rlink = pr;
          //  pr.llink = newnode.rlink;
            newnode.data = item;
            
            
            Console.WriteLine("Value placed at front is   " + newnode.data);
            //}
            /*else 
            {
                Console.WriteLine("over flow");
            }*/

        }
        public void InsertionAtLast(object vaule)
        {
            try
            {
                header.llink = null;
                Node pr = header;
                while (pr.rlink != null)
                {
                    pr = pr.rlink;
                }
                Node newnode = new Node();
                pr.rlink = newnode;
                newnode.llink = pr;
                newnode.data = vaule;
                newnode.rlink = null;
                Console.WriteLine("Value is placed at last " + newnode.data);
            }
            catch (Exception er)
            {
                Console.WriteLine(er.Message);
            }
        }
        public void IsertionAtAnyPlace(object value, object key)
        {
            header.llink = null;
            Node pr = header;
            Node newnod = new Node();

            while ((pr.data != key) && (pr.rlink != null))
            {
                pr = pr.rlink;
                Console.WriteLine("key is not matched");
                if (pr.data.ToString() == key.ToString())
                    break;
            }
            /*if (newnod == null)
            {
                Console.WriteLine("memory is not availble");
            }*/
            if (pr.rlink == null)
            {

                newnod.llink = pr;
                pr.rlink = newnod;
                newnod.rlink = null;
                newnod.data = value;
                Console.WriteLine("value placed at any place is " + newnod.data);
            }
            else
            {
                Node pr1;
                pr1 = pr.rlink;
                newnod.llink = pr;
                newnod.rlink = pr1;
                pr.rlink = newnod;
                pr1.llink = newnod;
                pr = newnod;
                newnod.data = value;
                Console.WriteLine("value placed at any place is two " + newnod.data);
            }
        }
        public void deletionatfront() 
        {
            Node pr = header.rlink;
            Node pr1 = pr.rlink;
            header.rlink = pr1.llink;
            Console.WriteLine("value is deleted from first is : " + pr.data);
        }
    }
}

Attached Files
File Type: docx double link list program in csharp.docx (35.2 KB, 322 views)
Reply With Quote
Reply

Tags
csharp, double, functions, linked, list, program


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
c sharp overloading program thecool Visual Programming 0 17-06-2011 09:49 PM
Array program in C sharp thecool Visual Programming 0 17-06-2011 08:59 PM
LLB 3 years program 4th merit list bzu 2010 Salman Mushtaq University News and Events 0 29-09-2010 06:03 PM
LLB 5 years program 3rd merit list bzu 2010 Salman Mushtaq University News and Events 0 27-09-2010 11:30 AM
1st merit list mba ii (2) program all pakistan Salman Mushtaq University News and Events 0 19-09-2010 12:49 PM

Best view in Firefox
Almuslimeen.info | BZU Multan | Dedicated server hosting
Note: All trademarks and copyrights held by respective owners. We will take action against any copyright violation if it is proved to us.

All times are GMT +5. The time now is 02:05 AM.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.