4 Replies - 1155 Views - Last Post: 12 August 2012 - 02:24 PM

#1 TechSyndrome  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 135
  • Joined: 06-May 12

Merge Lists

Posted 12 August 2012 - 01:29 PM

Hi. I think I've done the right thing by not creating a new topic. Please correct me if I'm wrong.

I've been given a question where I need to merge two sorted list-based sequences:

S1 = (1,5,8,12) S2 = (7,9,11,18)

1.

S1 = (5,8,12)
S2 = (7,9,11,18)
? = 1

2.

S1 = (8,12)
S2 = (7,9,11,18)
? = 1, 5

3.

S1 = (8,12)
S2 = (9,11,18)
? = 1, 5, 7

4.

S1 = (12)
S2 = (9,11,18)
? = 1, 5, 7, 8

5.

S1 = (12)
S2 = (11,18)
? = 1, 5, 7, 8, 9

6.

S1 = (12)
S2 = (18)
? = 1, 5, 7, 8, 9, 11

7.

S1 = ()
S2 = (18)
? = 1, 5, 7, 8, 9, 11, 12

8.

S1 = ()
S2 = ()
? = 1, 5, 7, 8, 9, 11, 12, 18

First, is this correct. And two, I feel I need to create a new variable to store the result, but what would I call it?

This post has been edited by TechSyndrome: 12 August 2012 - 02:25 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Merge Lists

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10387
  • View blog
  • Posts: 38,440
  • Joined: 27-December 08

Re: Merge Lists

Posted 12 August 2012 - 01:34 PM

Topic split and moved to computer science. Please open new threads to ask your questions rather than using existing resource threads.
Was This Post Helpful? 1
  • +
  • -

#3 TechSyndrome  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 135
  • Joined: 06-May 12

Re: Merge Lists

Posted 12 August 2012 - 01:54 PM

View Postmacosxnerd101, on 12 August 2012 - 01:34 PM, said:

Topic split and moved to computer science. Please open new threads to ask your questions rather than using existing resource threads.


Ok, will do. Thank you for correcting me.
Was This Post Helpful? 0
  • +
  • -

#4 sepp2k  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2089
  • View blog
  • Posts: 3,181
  • Joined: 21-June 11

Re: Merge Lists

Posted 12 August 2012 - 02:23 PM

View PostTechSyndrome, on 12 August 2012 - 10:29 PM, said:

First, is this correct.


Yepp.

Quote

And two, I feel I need to create a new variable to store the result, but what would I call it?


Unless the assignment specifically told you to use a certain name (which I assume it didn't or you wouldn't have asked), it doesn't really matter what you call. You could call it S3, or R like result or M like "merged". Or SR or SM. Or whatever.

Basically if a certain naming convention is used in your lecture, try to stick to that (so if sequences are always called "S[sub]something[/sub" you should stick with that for naming your result sequence). Otherwise just do what you feel like.

This post has been edited by sepp2k: 12 August 2012 - 02:24 PM

Was This Post Helpful? 1
  • +
  • -

#5 TechSyndrome  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 135
  • Joined: 06-May 12

Re: Merge Lists

Posted 12 August 2012 - 02:24 PM

View Postsepp2k, on 12 August 2012 - 02:23 PM, said:

View PostTechSyndrome, on 12 August 2012 - 10:29 PM, said:

First, is this correct.


Yepp.

Quote

And two, I feel I need to create a new variable to store the result, but what would I call it?


Unless the assignment specifically told you to use a certain name (which I assume it didn't or you wouldn't have asked), it doesn't really matter what you call. You could call it S3, or R like result or M like "merged". Or SR or SM. Or whatever.

Basically if a certain naming convention is used in your lecture, try to stick to that. Otherwise just do what you feel like.


Thank you so much, Sir!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1