Implement a program by using data structure

i've learn link-list,b-tree,red black tree,hash table. now it's time for me to implement a program using any one of these. i've no idea about how to start, and what kind of program should i write? what kind of program use data structure? i want some simple example program to make me understand. can anyone help me?
thank 4 u r time,
makio

what sort of program do use data structure? let's say
i want to use binary search on data , how can i?As nasch said: pretty much any program uses data structures.
Okay, let's say you want to try binary search. You could do that on an array, on a singly linked list, on a doubly linked list, probably on others that I can't think of right now.
If you just want practice using the data structures you've learned, then why not write a binary search over several different ones? That will give you a feel for how they differ in usage and performance.
Or, you can just pick any kind of program that interests you. Unless it's trivially small and simple, there will probably be a use for one or more of the data strux you've learned.
A chat program needs data structures to hold curently connected users, ongoing conversations, maybe a queue for messages waiting to be sent.
A card game needs to be able to search to see if a given card is in a given hand. Needs to hold all the cards in a deck that has to be shuffled. Dealing is like popping off a stack.
A database of students and their courses might want to keep something in an ordered tree--by last name for instance.
What applications interest you?

Similar Messages

  • Extending vs. Using Data Structures

    I'm fairly new to Java, though not to coding in general, and I'm wondering, whether its better to extend a data structure or to use one, when creating a class.
    For example, I've been messing around with some playing cards, and to make the deck, I essentially want to use a stack. Would it be better to create a Deck class that extends Stack, or to create a Deck class that contains a Stack object and methods that modify the Stack? I've tried it both ways, and they both seem to do okay, but I'm wondering which way is preferable.
    So far, inheriting seems more powerful, but using is much cleaner. (e.g. I don't have to worry about them calling pop() instead of draw())
    Edited by: chess19 on Mar 16, 2009 6:19 PM

    You seem to be on track in terms of the issues involved. If you google for the phrase "prefer composition to inheritance" you'll find a lot of people with relevant advice.

  • Implement a table menu using ALV

    Hi,
    I was wondering if its possible to implement a standard sap table menu bar into WDA using ALV?
    is there a doc that explains that?
    I'm looking for something similar to this
    [screenshot|http://www.mypicx.com/02202009/menubar/]
    Thanks in advance.

    what sort of program do use data structure? let's say
    i want to use binary search on data , how can i?As nasch said: pretty much any program uses data structures.
    Okay, let's say you want to try binary search. You could do that on an array, on a singly linked list, on a doubly linked list, probably on others that I can't think of right now.
    If you just want practice using the data structures you've learned, then why not write a binary search over several different ones? That will give you a feel for how they differ in usage and performance.
    Or, you can just pick any kind of program that interests you. Unless it's trivially small and simple, there will probably be a use for one or more of the data strux you've learned.
    A chat program needs data structures to hold curently connected users, ongoing conversations, maybe a queue for messages waiting to be sent.
    A card game needs to be able to search to see if a given card is in a given hand. Needs to hold all the cards in a deck that has to be shuffled. Dealing is like popping off a stack.
    A database of students and their courses might want to keep something in an ordered tree--by last name for instance.
    What applications interest you?

  • Customer Master using Appended structure KNA1

    Hi
    We have to update few ZZ description fields in ZAKNA1, which are not part of user interface in XD01/02/03. The available options are such as LSMW, Batch input require code addition through user exit ZXF04U01/ EXIT_SAPMF02D_001.
    I would like to use BAPI as we have a plan to use web services. Any idea how to extend the BAPI's such as BAPI_CUSTOMER_CHANGEFROMDATA1 or BAPI_CUSTOMER_CREATEFROMDATA1 using best practice?  I donu2019t find any extension structures like other BAPIu2019s have. Without ExtensionIn and ExtensionOut parameters, a BAPI can not be enhanced correct?
    The version we are using is ECC 5.0. Any ideas with customer master BAPI will be greatly appreciated.
    Bala

    Hi Bala,
    Just some general comments without having looked at your specific problem. Since you're on ECC 5.0 you cannot use the new [Enhancement Framework|http://help.sap.com/saphelp_nw2004s/helpdata/EN/94/9cdc40132a8531e10000000a1550b0/frameset.htm], which would make such changes more easy...
    A rather awkward workaround for extending the BAPI's is sometimes to add append structures to an IMPORT parameter of the BAPI. However, this is a rather dangerous and limited approach, because you might get into trouble depending on where the structures are used (i.e. if you add a field, it might cause harm in other programs that use the structure) and you also have to study the source code to see if you even could utilize those additional fields.
    A pretty generic option in lieu of other approaches is to generate a custom wrapper function module around the standard BAPI. Within your custom BAPI you can add the missing fields as parameters, call the standard BAPI and then do the additional updates. The big advantage of such a solution is that
    <ol>
    <li>Your change/additional logic is obvious (not hidden in a customer exit or BAdI, which are often harder to find when troubleshooting or changing functionality)</li>
    <li>Any changes to the standard BAPI will automatically also take effect in your custom BAPI (since you didn't copy the original one); this excludes of course interface changes, but here you anyhow would have to do something...</li>
    </ol>
    Should you have custom fields that are already exposed on the customer maintenance screens via enhancements, then you might want to consider using the wrapper approach, but simply export the additional data to memory, then call the standard BAPI and within the customer/user exits handling the additional fields fill them via an import from memory.
    Cheers, harald

  • Data structure for simulation of message queue

    Hello,
    I have undertaken a project of simulating the point to point and publish/subscribe protocols of message queueing. This whole project would be done just in Java. There won't be any system level programming. Which data structure in Java would be the most efficient one for the message queue?

    Hello,
    I have undertaken a project of simulating the point to point and publish/subscribe protocols of message queueing. This whole project would be done just in Java. There won't be any system level programming. Which data structure in Java would be the most efficient one for the message queue?

  • Asset Management on BPC: scripts using dates

    Hi all,
    I wonder whether any of you have already implemented any logic that uses dates, such as a calculation of asset's depreciation based on properties with acquisition dates (to put an example, I'm not exactly doing that). Basically I need to do some calculations about assets taking into account dates (like "begin calculation from date xx/xx/xxxx).
    Among the different functions available I don't find any to manage dates and calculate periods from dates. Could you please advice on any best practice/strategy on how to handle this?
    Regards,
    Rafa

    If you're running it as batch logic, you have a lot of flexibility using the *SELECT to retrieve just about anything that's in the database (except what's in the fact tables), into a variable. (I do this when I have a FirstPlanMonth of my forecast categories, and I only want certain logic to apply for plan months in the future, not months that have passed.) *SELECT also gives you access to pretty much the full SQL string manipulation capabilities, but again it's not working against data, just master data in member tables and the like. (Otherwise, string manipulation is limited. This is an OLAP cube with numbers, not a transactional system, so the logic focuses on numbers.)
    Another option is to *LOOKUP in a different time period, but the problem here is, you need to know what time period to look up in, before you look it up. Pretty hard to see how that could work.
    And then you can possibly compare one time period in the data, against another time period in your *SELECT or *LOOKUP, using a series of *WHEN *IS clauses, but it wouldn't be easy.
    The basic checking of whether a JUN < SEP is supported, though. This syntax works to do some basic conditional checking on the time period of the data submission, compared to FirstPlanMonth.
    *XDIM_MEMBERSET TIME = PRIOR(4),%TIME_SET%,NEXT(23)
    *WHEN TIME
    *IS PRIOR
    // do nothing for the months before the submitted time period.
    *IS Category.FirstPlanMonth
    // do something special for the first month -- have a sale!
    // and we might need to bring in the PRIOR(4) above, if we wanted to, for example, calculate A/R based on the prior 3 months' sales.
    *ELSE
    // do something boring for the next 23 months
    And I don't believe that you can change the member IDs of the time dimension, at least on BPC MS, to 200801. There are a number of places in the logic where it considers a PREFIX (the year) and a SUFFIX, and wants to see a period as the separator between these two. You can always try, and it's not documented anywhere that I've seen that it must be a certain way, but I learned to live with .JAN .FEB etc.

  • How to use event structure of event data nodes event filter nodes in programming

    hi,
    I need manual of how to use 'event structure' events of 'event data nodes' and 'event data filters'...please help me....
    Regards
    Ravindranath

    I'm not really sure what you are looking for here.  Did you do a search in the LabVIEW help for Event Structure?
    The Event Data Node just returns information about the event, like control data, control reference, what caused the event, etc.
    The Event Data Filters are just used in Filter Events.  This allows you to discard an event or change the data that the event will recieve.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Implementing a Graph Data Structure

    First time posting here, I was introduced to LabVIEW while participating in FIRST.
    I was reading about Graph Data Structures, and wanted to see if I could use them in LabVIEW, as it looked like a good way to relate information. Unfortunately, it appears that the straight forward way that I attempted will not work. I tried creating a typedef which consisted of a cluster of two elements, an array of linked nodes and an array of edge weights. Alas, I found you can't have recursive data types, as the array of linked nodes in the typedef needed to be the same as the typedef. I know why this is after a bit of searching, but I was wondering if there was a way to get around this. From my research, it seems like using a root class and a child class is one possible, but advanced way of doing it.
    I am currently thinking of just representing the linked nodes of a node as an array of index numbers which you can use to get the referenced nodes from the graph array. This means that the graph array cannot be sorted or otherwise modified so that the index numbers won't work, you can only add objects onto the end. Is this thinking right, or is there a different way to go about this?
    Solved!
    Go to Solution.

    Not an easy problem, as recursion is not native to LV programming (much less than any other language I used except assembler).
    But the solution to your index number problem is to use 'keys'. Each node should have a unique key (number), so you can adress it (search for the key) even if the array is sorted in some way.
    Again, it is not native to LV. This means, that you need to program the logic other languages use for that on your own (pseudo-pointers, handles, keys, hashes).
    From a practical side: I would not implement the graph in LV itself but access a graph from some other source (data base?) via an interface (ActiveX, .NET). To learn a bit more about how to do it, try playing around with the tree control (it is a limited graph).
    Felix
    www.aescusoft.de
    My latest community nugget on producer/consumer design
    My current blog: A journey through uml

  • Urgent! Need help in deciding data structure to use

    Hi all,
    I need to implement a restaurant system by which a customer can make a reservation.
    I was wondering whether vector would be able to be store such an object, The thing is I don't want a complex data structure. just sumthin simple cos i hardly have anytime left to my submission. sighz...
    The thing is I need to able to search based on 2 properties of an object. Eg. I need to search for a reservation based on the customer name and the date he reserved a table.
    But I am totally clueless how to search thru a vector based on 2 properties of the object... Would really appreciate some help. Like an example how to so so based on my program. Feelin so lost...This is all I have so far:
    class AddReservation
         static BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in));
         //Main Method
         public static void main (String[]args)throws IOException
              String custName, comments;
              int covers, date, startTime, endTime;
              int count = 0;
              //User can only add one reservation at a time
              do
                   //Create a new reservation
                   Reservation oneReservation=new Reservation();                         
                   System.out.println("Please enter customer's name:");
                   System.out.flush();
                   custName = stdin.readLine();
                   oneReservation.setcustName(custName);
                   System.out.println("Please enter number of covers:");
                   System.out.flush();
                   covers = Integer.parseInt(stdin.readLine());
                   oneReservation.setCovers(covers);
                   System.out.println("Please enter date:");
                   System.out.flush();
                   date = Integer.parseInt(stdin.readLine());
                   oneReservation.setDate(date);
                   System.out.println("Please enter start time:");
                   System.out.flush();
                   startTime = Integer.parseInt(stdin.readLine());
                   oneReservation.setstartTime(startTime);
                   System.out.println("Please enter end time:");
                   System.out.flush();
                   endTime = Integer.parseInt(stdin.readLine());
                   oneReservation.setendTime(endTime);
                   System.out.println("Please enter comments, if any:");
                   System.out.flush();
                   comments = stdin.readLine();
                   oneReservation.setComments(comments);
                   count++;
              while (count<1);
              class Reservation
              private Reservation oneReservation;
              private String custName, comments;
              private int covers, startTime, endTime, date;
              //Default constructor
              public Reservation()
              public Reservation(String custName, int covers, int date, int startTime, int endTime, String comments)
                   this.custName=custName;
                   this.covers=covers;
                   this.date=date;
                   this.startTime=startTime;
                   this.endTime=endTime;
                   this.comments=comments;
              //Setter methods
              public void setcustName(String custName)
                   this.custName=custName;
              public void setCovers(int covers)
                   this.covers=covers;;
              public void setDate(int date)
                   this.date=date;
              public void setstartTime(int startTime)
                   this.startTime=startTime;
              public void setendTime(int endTime)
                   this.endTime=endTime;
              public void setComments(String comments)
                   this.comments=comments;
              //Getter methods
              public String getcustName()
                   return custName;
              public int getCovers()
                   return covers;
              public int getDate()
                   return date;
              public int getstartTime()
                   return startTime;
              public int getendTime()
                   return endTime;
              public String getComments()
                   return comments;
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    class searchBooking
         static BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in));
         public static void main (String[]args)throws IOException
              int choice, date, startTime;
              String custName;
                   //Search Menu
                   System.out.println("Search By: ");
                   System.out.println("1. Date");
                   System.out.println("2. Name of Customer");
                   System.out.println("3. Date & Name of Customer");
                   System.out.println("4. Date & Start time of reservation");
                   System.out.println("5. Date, Name of customer & Start time of reservation");
                   System.out.println("Please make a selection: ");          
                   //User keys in choice
                   System.out.flush();
                   choice = Integer.parseInt(stdin.readLine());
                   if (choice==1)
                        System.out.println("Please key in Date (DDMMYY):");
                        System.out.flush();
                        date = Integer.parseInt(stdin.readLine());
                   else if (choice==2)
                             System.out.println("Please key in Name of Customer:");
                             System.out.flush();
                             custName = stdin.readLine();
                   else if (choice==3)
                             System.out.println("Please key in Date (DDMMYY):");
                             System.out.flush();
                             date = Integer.parseInt(stdin.readLine());
                             System.out.println("Please key in Name of Customer:");
                             System.out.flush();
                             custName = stdin.readLine();
                   else if (choice==4)
                             System.out.println("Please key in Date (DDMMYY):");
                             System.out.flush();
                             date = Integer.parseInt(stdin.readLine());
                             System.out.println("Please key in Start time:");
                             System.out.flush();
                             startTime = Integer.parseInt(stdin.readLine());
                   else if (choice==5)
                             System.out.println("Please key in Date (DDMMYY):");
                             System.out.flush();
                             date = Integer.parseInt(stdin.readLine());
                             System.out.println("Please key in Name of Customer:");
                             System.out.flush();
                             custName = stdin.readLine();
                             System.out.println("Please key in Start time:");
                             System.out.flush();
                             startTime = Integer.parseInt(stdin.readLine());
                        }

    Please stop calling your questions urgent. Everybody's question is urgent to them. Nobody's are urgent to the people who are going to answer them. Calling your questions urgent suggests that you think they are more important than others' (They're not.) and will only serve to irritate those who would help you. It won't get your questions answered any sooner.

  • Efficient data structure to implement simple text editor?

    I was given this problem in an interview:
    What data structure would you use to implement a simple text editor that does these 4 functions:
    a) goto(line number)
    b) insert(char input,location)
    c) delete(location)
    d) printAll() //print entire file
    Given that i'm such a newb, i was stumped. I came up with making a 2d array that would allow for o(1) time for goto, but o(n) for everything else (shifting everything in the array). there were other downfalls too dealing with space issues and such, but he wanted me to optimize this data structure. I then came up with a linked list of arrays, but that had similar problems.
    But thinking about it further is driving me a little crazy so I'm wondering if you guys have any suggestions on how to answer this question...
    one thing that came to mind after is to implement the data structure as a binary tree, where each node contains
    class Node
    char theChar
    int position; // ie 0 = first character in the file, and 81 could be the first character in the 2nd line
    node left,right,parent;
    }so how it works is the cursor would know where the location was so i would know where to delete and insert within the tree.
    insert {
         //search for location to insert after (log n)
           //create new character node and append to current node
         //increment position for all subsequent children
    delete(x) {
         search for x position
         if found, remove node and decrement position value for all children
    goto(line #) {
         return line # * 80 (or whatever max length for a single line)
    }the major problem i see here is balancing the tree after every insert/delete
    Thanks in advance.

    One of many great things emacs has given us is the gap buffer:
    http://en.wikipedia.org/wiki/Gap_buffer
    To see a Java implementation of this you can look in the Java SDK source. The document model (I forget exactly what its called), used in Swing uses a gap buffer.

  • Using a single data structure in a desktop application

    Hello,
    I am programming an application that needs to constantly access a data structure, for instance to add / edit / update / search data. Several graphical user interfaces need to modify this data structure. I was wondering of easy ways to use the data structure throught the whole application. One solution I found was to use the singleton pattern for my data structure, though lots of people have recommended me to avoid using that pattern. What are better ways of accessing that single data structure from all of those GUIs ?
    Thank you,
    Alfredo

    Not that there is anything wrong with a Singleton pattern, but I don't see how it would help you in this case.
    Just create the DataStructure and let every GUI that need to use it have a reference to it.

  • SQ02 - Create InfoSet using 'Data retrieval by program'

    Using SQ02, I would like to use the data returned by an ABAP program as the data source for an InfoSet.  When attempting to create an InfoSet, I noticed the 'Data retrieval by program' option.  I would like to discover how to use this option and how to pass parameters to the ABAP program I'd like to use.

    The "Data retrieval program" would be coded like any normal report except for adding a few comment tags that will be used by SQ01 query generator as placeholders to insert its own code into your code to generate the query program.
    In general this is how a data retrieval program is coded. SQ01 when it generates the query will insert its own code in place of *<Query_body> and *<Query_head> comment tags
    REPORT ztest_sq01_driver_program.
    TABLES: <name of dictionary structure of your infoset>.
    * DATA declarations
    START-OF-SELECTION.
    *<Query_head>
    * <Fetch your data here and store it in an internal table gt_report> that has all the fields that you need in your query
    END-OF-SELECTION.
      LOOP AT gt_report INTO gs_report.
        MOVE-CORRESPONDING gs_report TO <name of dictionary structure of your infoset>
    *<Query_body>
      ENDLOOP.

  • When to use specific data structures

    Hi
    I'm currently learning Java and have found a wealth of information on data structures (link lists,queues et. al.) but I'm finding not much material on when best to apply specific data structures and the advantages and disadvantages. Could anyone point me to any resources?
    Second question as a Java developer do you actually use things like linked lists etc regularly?
    Thanks in advance

    I suppose that a wealth of information exists because data structures are an integral part of programming. In simpler terms, all that information exists because the answer to question two is yes, absolutley.
    The answer to question one is a bit trickier. It's kind of like asking when is best to use a flathead vrs. a phillips screwdriver. The answer seems obvious within a given context, but obscure outside of one.
    IMHO: The 'when' becomes clear with experience. Focus on the 'how' and you'll be ready when you are faced with a problem that calls for a particular type of solution.
    jch

  • Can I automate the creation of a cluster in LabView using the data structure created in an autogenerated .CSV, C header, or XML file?

    Can I automate the creation of a cluster in LabView using the data structure created in an auto generated .CSV, C header, or XML file?  I'm trying to take the data structure defined in one or more of those files listed and have LabView automatically create a cluster with identical structure and data types.  (Ideally, I would like to do this with a C header file only.)  Basically, I'm trying to avoid having to create the cluster by hand, as the number of cluster elements could be very large. I've looked into EasyXML and contacted the rep for the add-on.  Unfortunately, this capability has not been created yet.  Has anyone done something like this before? Thanks in advance for the help.  
    Message Edited by PhilipJoeP on 04-29-2009 04:54 PM
    Solved!
    Go to Solution.

    smercurio_fc wrote:
    Is this something you're trying to do at runtime? Clusters are fixed data structures so you can't change them programmatically. Or, are you just trying to create some typedef cluster controls so that you can use them for coding? What would your clusters basically look like? Perhaps another way of holding the information like an array of variants?
    You can try LabVIEW scripting, though be aware that this is not supported by NI. 
     Wow!  Thanks for the quick response!  We would use this cluster as a fixed data structure.  No need to change the structure during runtime.  The cluster would be a cluster of clusters with multiple levels.  There would be not pattern as to how deep these levels would go, or how many elements would be in each.   Here is the application.  I would like to be able to autocode a Simulink model file into a DLL.  The model DLL would accept a Simulink bus object of a certain data structure (bus of buses), pick out which elements of the bus is needed for the model calculation, and then pass the bus object.  I then will take the DLL file and use the DLL VI block to pass a cluster into the DLL block (with identical structure as the bus in Simulink).  To save time, I would like to auto generate the C header file using Simulink to define the bus structure and then have LabView read that header file and create the cluster automatically.   Right now I can do everything but the auto creation of the cluster.  I can manually build the cluster to match the Simulink model bus structure and it runs fine.  But this is only for an example model with a small structure.  Need to make the cluster creation automated so it can handle large structures with minimal brute force. Thanks!  

  • How to make use of structure in my program

    hai!
          i want to know how i can use the structure "rstxt'
    which contains a field by name "txline". this structure is used to hold basic data text present in basicdata1 view
    of transaction mm01. i want to know how i can access this structure in my pgm.here, i want to check this basic data text and if proper data text is not present then  i am trying to  call transaction mm02 using bdc.
    any help is appreciated.<b></b>

    Hi, Try this example
    DATA:BEGIN OF ITAB OCCURS 10,
          QMNUM LIKE QMEL-QMNUM,
          DESC(72),
         END OF ITAB.
    DATA:F_TDOBJECT LIKE THEAD-TDOBJECT,
         F_TDNAME   LIKE THEAD-TDNAME,
         F_TDID     LIKE THEAD-TDID,
         ITAB_LINES LIKE TLINE OCCURS 0 WITH HEADER LINE.
          F_TDID     = 'LTQM'.
          F_TDNAME = T_DET-QMNUM.
          F_TDOBJECT = 'QMMA'.
          CALL FUNCTION 'READ_TEXT'
            EXPORTING
              CLIENT                  = SY-MANDT
              ID                      = F_TDID
              LANGUAGE                = SY-LANGU
              NAME                    = F_TDNAME
              OBJECT                  = F_TDOBJECT
            TABLES
              LINES                   = ITAB_LINES
            EXCEPTIONS
              ID                      = 1
              LANGUAGE                = 2
              NAME                    = 3
              NOT_FOUND               = 4
              OBJECT                  = 5
              REFERENCE_CHECK         = 6
              WRONG_ACCESS_TO_ARCHIVE = 7
              OTHERS                  = 8.
          DESCRIBE TABLE ITAB_LINES LINES SY-TFILL.
          IF SY-TFILL > 0.
            LOOP AT ITAB_LINES.
              ITAB-QMNUM = T_DET-QMNUM.
              ITAB-DESC = ITAB_LINES-TDLINE.
              APPEND ITAB.
              CLEAR ITAB.
            ENDLOOP.
          ENDIF.
    reward points if it helps
    kaki

Maybe you are looking for

  • AFP won't connect since upgrading to Mavericks

    Since upgrading to Mavericks I cannot connect to my QNAP TS-210 via AFP; this means my Time Machine can no longer find my backup disk and no longer works. Anyone else having similar issues? I have tried the usual quick fixes: Firmware is up to date A

  • Vista x64 / Logitech Orbit MP / XFi Platinum problem confirmed... PLEASE RE

    I was wondering why my 7. option disappeared from my speakers configuration option. Turns out another person had the same issue with his computer and found out that unplugging his Orbit MP fixed the problem. (It was limiting his sound to 5.) Well I h

  • How can I edit a pdf picture

    How can I edit a picture that is a pdf and not a photo?

  • What is the error in this program??????

    class FindArea public static void main(String args[]) float radius=7.0f; float area=(22/7)*(radius)*(radius); System.out.println(area); When i execute the above program i am getting output as 147.0 why it is happening???? I dont understand..... Actua

  • Toplink changes table and columns to uppercase

    I found a way to make toplink not to change table and columns to upercase with setShouldForceFieldNamesToUpperCase=false setting (which should be false be default but so some reason isn't.) However, when toplink is used with JSF how can setShouldForc