Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6193761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:10:35+00:00 2026-05-24T03:10:35+00:00

Having a singly linked list with its nodes being BST’s, what is the code

  • 0

Having a singly linked list with its nodes being BST’s, what is the code in c++ which needs to be used in order for me to be able to access the elements of the BST?

ifstream isd;

isd.open ( "book1.txt" );
while( !isd.eof (  ) ) {
    book b1;

    isd >> b1;
    b[i] = b1;
    i++;
}

isd.close (  );
int j = 0;

for( int k = 0; k < 104; k++ ) {
    if( b[k].category == "adventure" )
        bcat[j].insert ( b[k] );
    if( b[k].category == "family" )
        bcat[j + 1].insert ( b[k] );
    if( b[k].category == "fiction" )
        bcat[j + 2].insert ( b[k] );
    if( b[k].category == "fun" )
        bcat[j + 3].insert ( b[k] );
    if( b[k].category == "history" )
        bcat[j + 4].insert ( b[k] );
    if( b[k].category == "horror" )
        bcat[j + 5].insert ( b[k] );
}

if( b[k].category == "mystery" )
    bcat[j + 6].insert ( b[k] );
if( b[k].category == "school" )
    bcat[j + 7].insert ( b[k] );
if( b[k].category == "science" )
    bcat[j + 8].insert ( b[k] );
if( b[k].category == "story" )
    bcat[j + 9].insert ( b[k] );
if( b[k].category == "suspence" )
    bcat[j + 10].insert ( b[k] );


for( int k = 0; k < 11; k++ )
    sdb.insert ( bcat[k] );

BinNode < Elem > preorder ( BinNode < Elem > *subroot )
{
    if( subroot == NULL )
        break;
    book ele;

    return ele = subroot->val (  );
}

for( b1.setStart (  ); b1.getValue ( ro ); b1.next (  ) ) {
    b2 = ro.getroot (  );
    b3 = b2->val (  );
    if( r.Category == b3.category ) {   //compare titles in order to find the correct title 
    }
}

After reading from the file the books..i inserted them into an array of bst depending on their category then i inserted them into the linked list. I just need to be able to access the nodes of the bst.

BST<string,book,titlebookcomp,bookcomp> ro;
BinNode<book> b2;
book b3;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:10:36+00:00Added an answer on May 24, 2026 at 3:10 am

    Why not roll your own algorithm? How are the BSTs ordered in the list? It should be a fairly simple exercise to do this. I’m not sure there is built-in (e.g. STL) support for lists of BSTs. If you clarify your problem, lots of people here would help you write an algorithm to do anything you want.

    EDIT:

    Here’s some pseudocode. Tell me what is wrong about this or where you are having trouble implementing it:

      FindBook(mylist, cat, tit)
       1. while mylist != null do
       2.    if mylist.root.category = cat then
       3.       BSTnode = mylist.root
       4.       while BSTnode != null do
       5.          if BSTnode.title = tit then
       6.             print "Found title %s, category %s in BST %s", tit, cat, mylist
       7.             return true
       8.          elsif BSTnode.title < tit then
       9.             BSTnode = BSTnode.right
      10.          else
      11.             BSTnode = BSTnode.left
      12.    mylist = mylist.next
      13. print "Did not find title %s, category %s", tit, cat
      14. return false
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been thinking of how to implement a lock-free singly linked list. And to
How would I create a linked list to hold my data in OCaml? I'm
I am having a discussion with someone about the following table that is used
I have written a list-like template class sll (Single Linked List). Now, I am
I got a problem here, implementing a Sorted Doubly Linked List of first and
I am making a program for singly linked lists using multiple files and classes.
I am making a program for singly linked lists using multiple files and classes.
[SOLVED] So I decided to try and create a sorted doubly linked skip list...
I'm using singly linked lists, in C, without the pointer to the node value.
Having single AMQ broker and 100 consumers connected. I would send the message to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.