answersLogoWhite

0


Best Answer

You have two options here.

For the first you have to ask yourself, "Is my data continuously sorted by the list itself?" If you answered 'yes' then you can simply add all data from one list to the other and the combined list will be sorted.

If you answered 'no' to the above question, then it means you have two lists which are currently sorted, but which may not remain that way if new elements are added to them.

Let's look at some steps to merge all elements list1 and list2 into a separate list3. (We'll assume data is sorted from least to greatest).

1) Start two index counters (one for each list) which point to the start of the list.

2) Is the element at list1[index1] less than the element at list2[index2]?

  1. If so, add list1[index1] to the end of list3 and increment index1.
  2. If not, add list2[index2] to the end of list3 and increment index2.

3) If either index has reached the end of its list, then add the remaining elements from the other list to list3 and we're done.

4) Otherwise, go back to step 2.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: A merge algorithm which will merge two sorted lists into one sorted list?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What advantages of a sorted list over a linked list?

All lists are linked lists; there is no such thing as a separate "sorted list". There are algorithms that can sort a list, of course, but they all work on linked lists.


Definition of merge sort in data structure?

we can sort unordered list to order list. we fallow a mechanism given list divided into two parts take one-one part ordered them


Can I see the list of all artists with the first name Mario?

I am sorry, all lists are always sorted by last name.


What is a bubble sort used for?

Bubble sort, incorrectly referred to as sinking sort is a simple sorting algorithm (step by step procedure of calculations) that works to repeatedly step through list to be sorted. With the comparing of each adjacent items and swapping them into the correct order. This repeated until there are no swaps needed and the list of items are sorted.


Why do they name hurricanes the names they do?

The names are selected from predetermined lists sorted in alphabetical order. As each tropical storm develops it gets the next name on the list.


Insert in a sorted list?

Means to put a new item in the proper place in a sorted list.


What is the relation of database in a mail merge?

A mail merge just merges a word processing document with data from a data base. When you are doing a mail merge you will have a list of data, such as names and addresses that you want for your document. These can be stored in a database, which means you have them if you need them again. As they are in a database there are other things you could do, like print them in a sorted order or exclude some by setting criteria or filters.A mail merge just merges a word processing document with data from a data base. When you are doing a mail merge you will have a list of data, such as names and addresses that you want for your document. These can be stored in a database, which means you have them if you need them again. As they are in a database there are other things you could do, like print them in a sorted order or exclude some by setting criteria or filters.A mail merge just merges a word processing document with data from a data base. When you are doing a mail merge you will have a list of data, such as names and addresses that you want for your document. These can be stored in a database, which means you have them if you need them again. As they are in a database there are other things you could do, like print them in a sorted order or exclude some by setting criteria or filters.A mail merge just merges a word processing document with data from a data base. When you are doing a mail merge you will have a list of data, such as names and addresses that you want for your document. These can be stored in a database, which means you have them if you need them again. As they are in a database there are other things you could do, like print them in a sorted order or exclude some by setting criteria or filters.A mail merge just merges a word processing document with data from a data base. When you are doing a mail merge you will have a list of data, such as names and addresses that you want for your document. These can be stored in a database, which means you have them if you need them again. As they are in a database there are other things you could do, like print them in a sorted order or exclude some by setting criteria or filters.A mail merge just merges a word processing document with data from a data base. When you are doing a mail merge you will have a list of data, such as names and addresses that you want for your document. These can be stored in a database, which means you have them if you need them again. As they are in a database there are other things you could do, like print them in a sorted order or exclude some by setting criteria or filters.A mail merge just merges a word processing document with data from a data base. When you are doing a mail merge you will have a list of data, such as names and addresses that you want for your document. These can be stored in a database, which means you have them if you need them again. As they are in a database there are other things you could do, like print them in a sorted order or exclude some by setting criteria or filters.A mail merge just merges a word processing document with data from a data base. When you are doing a mail merge you will have a list of data, such as names and addresses that you want for your document. These can be stored in a database, which means you have them if you need them again. As they are in a database there are other things you could do, like print them in a sorted order or exclude some by setting criteria or filters.A mail merge just merges a word processing document with data from a data base. When you are doing a mail merge you will have a list of data, such as names and addresses that you want for your document. These can be stored in a database, which means you have them if you need them again. As they are in a database there are other things you could do, like print them in a sorted order or exclude some by setting criteria or filters.A mail merge just merges a word processing document with data from a data base. When you are doing a mail merge you will have a list of data, such as names and addresses that you want for your document. These can be stored in a database, which means you have them if you need them again. As they are in a database there are other things you could do, like print them in a sorted order or exclude some by setting criteria or filters.A mail merge just merges a word processing document with data from a data base. When you are doing a mail merge you will have a list of data, such as names and addresses that you want for your document. These can be stored in a database, which means you have them if you need them again. As they are in a database there are other things you could do, like print them in a sorted order or exclude some by setting criteria or filters.


Which algorithm is efficient for finding an element from a sorted list?

Basically you split the list in two, looking at the element in the middle of the list. If the list is in ascending order, and the element you are looking for is SMALLER than the element in the middle of the list, you repeat this procedure for the FIRST half of the list (again, splitting it in two); if it is LARGER, you repeat for the SECOND half of the list.


Do you have to use an existing list for recipient information in the mail merge wizard?

You can use an existing list OR create a new one from scratch. Mailing lists are saved in a separate files with the extension ".mdb"(Ms Access file format).Those lists have to be merged with Word document (hence the name Mail merge)To create a new list Go to Mailings Tab, Button 'Select Recipients'. Clicking the button will show a drop down menu. Select option 'Type New list'


Where can I find an online list of Dental Assisting schools?

Ada.org is the official American Dental Association website which lists credited dental assisting schools. They are sorted by state and program.


Why comparisons are less in merge sort than insertion sort?

the main reason is: Merge sort is non-adoptive while insertion sort is adoptive the main reason is: Merge sort is non-adoptive while insertion sort is adoptive


How selection sort work?

Selection sortSelection sort is a sorting algorithm, specifically an in-place comparison sort. It has O(n2) time complexity, making it inefficient on large lists, and generally performs worse than the similar insertion sort. Selection sort is noted for its simplicity, and also has performance advantages over more complicated algorithms in certain situations, particularly where auxiliary memory is limited.AlgorithmThe algorithm works as follows:Find the minimum value in the listSwap it with the value in the first positionRepeat the steps above for the remainder of the list (starting at the second position and advancing each time)Effectively, the list is divided into two parts: the sub list of items already sorted, which is built up from left to right and is found at the beginning, and the sub list of items remaining to be sorted, occupying the remainder of the array.MANISH SONI CGC MOHALI MCA FIRST SEM