# Merge Lists

Page 1 of 1

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

### #1 TechSyndrome

Reputation: 3
• 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

• Games, Graphs, and Auctions

Reputation: 11790
• Posts: 44,310
• Joined: 27-December 08

## Re: Merge Lists

Posted 12 August 2012 - 01:34 PM

### #3 TechSyndrome

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

## Re: Merge Lists

Posted 12 August 2012 - 01:54 PM

macosxnerd101, on 12 August 2012 - 01:34 PM, said:

Ok, will do. Thank you for correcting me.

### #4 sepp2k

• D.I.C Lover

Reputation: 2308
• Posts: 3,570
• Joined: 21-June 11

## Re: Merge Lists

Posted 12 August 2012 - 02:23 PM

TechSyndrome, 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

### #5 TechSyndrome

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

## Re: Merge Lists

Posted 12 August 2012 - 02:24 PM

sepp2k, on 12 August 2012 - 02:23 PM, said:

TechSyndrome, 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!