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

  • Home
  • SEARCH
  • 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 782417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:23:01+00:00 2026-05-14T20:23:01+00:00

struct Record_node* Sequential_search(struct Record_node *List, int target) { struct Record_node *cur; cur = List->head

  • 0
struct Record_node* Sequential_search(struct Record_node *List, int target) { 
    struct Record_node *cur;
    cur = List->head ;
    if(cur == NULL || cur->key >= target) {
        return NULL;
    }
    while(cur->next != NULL) {
        if(cur->next->key >= target) {
            return cur;
        }
        cur = cur->next;
    }
    return cur;
}

I cannot interpret this pseudocode. Can anybody explain to me how this program works and flows? Given this pseudocode that searches for a value in a linked list and a list that is in an ascending order, what would this program return?

a. The largest value in the list that is smaller than target
b. The largest value in the list that is smaller than or same as target
c. The smallest value in the list that is larger than or same as target
d. Target
e. The smallest value in the list that is larger than target

And say that List is [1, 2, 4, 5, 9, 20, 20, 24, 44, 69, 70, 71, 74, 77, 92] and target 15, how many comparisons are occurred? (here, comparison means comparing the value of target)

EDIT:
@Stephen I am sorry if I have been rude asking my question.

Well, since I am used to programming in Visual Basic, I understand ‘cur->key’ in line 4 of the program as ‘cur is larger than or same as key’, but since ‘+=’ means ‘former value plus the latter value equals the latter value’, I can interpret ‘->’ in the same manner as ‘+=’ This part is one of the problems I am facing.

The second problem I am facing is the use of pointers in Record_node(if it is a pointer). I’m not even sure if I know what I don’t know! I understand this program as some kind of a recursive algorithm.

  • 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-14T20:23:02+00:00Added an answer on May 14, 2026 at 8:23 pm

    Well, since I am used to programming in Visual Basic, I understand ‘cur->key’ in line 4 of the program as ‘cur is larger than or same as key’, but since ‘+=’ means ‘former value plus the latter value equals the latter value’, I can interpret ‘->’ in the same manner as ‘+=’ This part is one of the problems I am facing.

    That’s where the problem is, I’m glad you clarified that 🙂

    This code is written in c (or c++). That language uses -> to dereference pointers and point to members of a struct. IIRC, VB doesn’t have pointers, so you would say struct.member or cur.next.

    while (cur->next != NULL) {   // While current's next node isn't NULL.
    }
    

    NULL is being used to signify the end of the list.

    Evaluating the cur->next->key means “the key of the node after the current one”. It may help you visualize this if you draw a linked list with ascending values and trace the program.

    At some point during execution of the while loop, you’ll have this:

    +-+  +-+  +-+
    |2|--|4|--|7|--NULL
    +-+  +-+  +-+
     ^    ^    ^
     |    |    |
     head cur  cur->next
    

    BTW, the real greater-than-or-equal-to operator is >=.

    BTW2, it’s not recursive. Recursive would be a function that calls itself (you could implement this recursively). This function is iterative (it uses loops). An example of a recursive algorithm is:

    node* Sequential_search(List *list, int target) {
      if (!list) return NULL;
      if (target == list->key) return list;
      return Sequential_search(list->next, target);
    }
    

    Hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 542k
  • Answers 542k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer That's not possible to do using the standard methods which… May 17, 2026 at 3:11 am
  • Editorial Team
    Editorial Team added an answer Personally, I wouldn't worry about creating dependencies between unit tests.… May 17, 2026 at 3:11 am
  • Editorial Team
    Editorial Team added an answer Why not use Jquery to call CKEditor to replace your… May 17, 2026 at 3:11 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a datastructure struct record { char cont[bufferSize]; record *next; }; When I
struct Record { char Surname[20]; char Initial; unsigned short int Gender; //0 = male
I've the following structure in C#: [StructLayoutAttribute(LayoutKind.Sequential)] public struct RECORD { public uint m1;
I have any array of structs. Each struct in the array has the following
I'm writing a program with struct Record. As I read in records from text
My question's pretty basic, but it's been a while. I'm reading in a text
I'm using nHibernate with c# to get a list of records or strings from
I have made the following linked list which is not printing the list .The
I'm trying to make a key logger for Mac OS for one of my
I am trying to make a function that sorts the linked list,which sorts the

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.