LogoLogo
    LogoLogo
    • TutoringPricingFor schools
    1. Home
    2. IB
    3. Computer Science (CS)
    4. Questions

    The names of vegetables must be always held in alphabetical order in a list in the main memory. The application program should allow insertion and deletion of the names of vegetables from this list.

    Question
    HLPaper 1

    The names of vegetables must be always held in alphabetical order in a list in the main memory. The application program should allow insertion and deletion of the names of vegetables from this list.

    1.

    Compare the use of a dynamic linked list for holding these names of vegetables with a static one-dimensional array.

    [3]
    Verified
    Solution

    Award [1] for each comparison, up to [3 max]. The size of the dynamic list does not have to be predetermined as in an array; The size of the dynamic list is not fixed whilst the size of an array is always fixed; If names are sorted they can be added/deleted (more easily) by changing the pointers without having to shuffle the names; As records can be dynamically added/deleted the memory is better used because there are no wasted / missing spaces as in an array;

    2.

    Sketch a single linked list holding these vegetables: potato, asparagus, lettuce, radish.

    [2]
    Verified
    Solution

    Award [1] for a node containing two fields / data(name) and link (pointer) to the next node and [1] for showing an external pointer pointing to the first vegetable on the list, and null pointer in the last node, and pointers which link the nodes in alphabetical orderup to [2 max].

    3.

    List the steps required to insert cabbage into the linked list.

    [4]
    Verified
    Solution

    Award [1]for each step identified up to [4 max]. Create a new node containing cabbage; Traverse the list (from the beginning) to find the place to insert a new node; Cabbage should be inserted before lettuce and after asparagus; The pointer in new (cabbage) node should be set to point to the node that is before the insertion point / lettuce; The pointer in node before insertion point / asparagus / should now point to the new node / cabbage; Note: award marks for clearly labelled diagrams in candidates'answers.

    4.

    Explain why deleting the first node in this list is different to deleting other nodes.

    [2]
    Verified
    Solution

    Award [1]for identifying a reason why deleting the first node is different to deleting other nodes and [1] for an expansion up to [2 max]. External pointer (First) must be changed/only in situation when deleting the beginning node the external pointer must be changed; And set to the pointer in the link field of the first node (Asparagus) which points to the second node/Lettuce;

    Sign up for free to view this answer

    5.

    State the dynamic data structure suitable for maintaining this list of vegetables which will allow faster searching for a given vegetable name.

    [1]
    Verified
    Solution

    Award [1 max]. Binary tree;

    Sign up for free to view this answer

    6.

    Sketch the data structure suggested in part containing the vegetable names sorted in alphabetical order. The vegetable names are input in the following order: potato, asparagus, lettuce, radish.

    [3]
    Verified
    Solution

    Award [3 max]. Award [1] for clearly a binary tree and the root is Potato. Award [1] for the correct left subtree. Award [1] for the correct right subtree.

    Sign up for free to view this answer

    Still stuck?

    Get step-by-step solutions with Jojo AI

    FreeJojo AI

    Want more practice questions for Computer Science (CS)?

    Related topics

    5.1 Abstract data structures

    Join 350k+ Students Already Crushing Their Exams

    Footer

    General

    • Pricing
    • About us
    • Mission
    • Tutoring
    • Blog
    • Jojo for SAT

    Company

    • State of learning survey

    • RevisionDojo vs OthersNew

    • Content philosophy
    • Trustpilot
    • Contact us
    • Join us

    Features

    • Jojo AI
    • Questionbank
    • Study notes
    • Flashcards
    • Test builder
    • Exam mode
    • Coursework
    • IB grade calculator

    Legal

    • Terms and conditions
    • Privacy policy
    • Cookie policy
    • Trust Center

    IB Subjects

    • Biology
    • Business Management
    • Chemistry
    • Chinese A Lang & Lit
    • Chinese B
    • Computer Science (CS)
    • Design Technology (DT)
    • Design Technology (First Exam 2027)
    • Digital Society (DS)
    • Economics
    • English B
    • English Lang & Lit
    • English Lit
    • Environmental systems and societies (ESS - Old)
    • Environmental systems and societies (ESS)
    • French A
    • French AB initio
    • French B
    • Geography
    • German A
    • German AB initio
    • German B
    • Global Politics
    • History
    • Mathematics Analysis and Approaches (AA)
    • Mathematics Applications & Interpretation (Math AI)
    • Physics
    • Psychology
    • Spanish A
    • Spanish AB initio
    • Spanish B
    • Sports, exercise and health science (SEHS - Old)
    • Sports, exercise and health science (SEHS)
    • Theory of Knowledge (TOK)
    Logo

    © 2022 - 2025 RevisionDojo (MyDojo Inc)

    RevisionDojo was developed independently of the IBO and as such is not endorsed by it in any way.

    SAT® is a trademark registered and owned by the College Board®, which is not affiliated with and does not endorse this product or site.

    RedditInstagramTikTokDiscord