473,321 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Array manipulation and merging.

22
Write the following functions that can be called by a C program:

Write a function to populate an array with random integers between 0 and 99. Use the following functions of which the prototypes are to be found in stdlib.h
• randomize() – use once to initialize the randomization process
• rand() – generates a random number between 0 and the maximum value for an integer. You can scale the values down by means of the modulus.

Write a function to remove duplicates from an array of integers.

Write a function to sort an array in ascending order .The following is a simple sorting algorithm

Expand|Select|Wrap|Line Numbers
  1. . int arr[n];
  2. int i, j, n, temp;
  3.  
  4. /* populate the array*/
  5.  
  6. for (i = 0; i < n-1; i++)
  7.    for (j = i+1; j < n; j++)
  8.       if (arr[i] > arr[j]) {
  9.     temp = arr[i];
  10.     arr[i] = arr[j];
  11.     arr[j] = temp;
  12.      }
  13.  
Write a function that will merge the contents of two sorted (ascending order) arrays of type integer values, storing the results in an array output parameter (still in ascending order). The function should not assume that both its input parameter arrays are the same length, but can assume that one array does not contain two copies of the same value. The result array should also contain no duplicate values. Write a function to execute a binary search algorithm to search for a value in an array. Use the following algorithm
Expand|Select|Wrap|Line Numbers
  1. int arr[n];
  2. int low = 0, high = n, mid, value;
  3.  
  4. while (low < high) {
  5.     mid = (low + high) / 2;
  6.     if (arr[mid] < value)
  7.         low = mid + 1;
  8.      else
  9.           high = mid;
  10.      }
  11.  
low will now be the index where value can be found.
Mar 14 '07 #1
11 4145
Ganon11
3,652 Expert 2GB
What work have you done?
Mar 14 '07 #2
sicarie
4,677 Expert Mod 4TB
holla!

(Sorry, I couldn't resist.) Ok, you have a lot of stuff in there - could you ask a bit more pointed of a question? I'm betting the code in there was already provided for you - so it looks like you need to populate the array, remove duplicates from it, and merge two arrays. What did you need help with there (or am I missing something)?
Mar 14 '07 #3
holla
22
holla!

(Sorry, I couldn't resist.) Ok, you have a lot of stuff in there - could you ask a bit more pointed of a question? I'm betting the code in there was already provided for you - so it looks like you need to populate the array, remove duplicates from it, and merge two arrays. What did you need help with there (or am I missing something)?
u are not missing anything the thing is that i have started with programming this year i could not figure out what happening.u write a function that can populate an array(btw integers 0 and 99) then u remove duplicates from it and merge the two
Mar 14 '07 #4
holla
22
What work have you done?
i am studing computer engineering
Mar 14 '07 #5
Ganon11
3,652 Expert 2GB
OK, but what have you done in an attempt to solve this problem on your own? Are you having trouble with a part of it, or are you asking us to write the program for you?
Mar 14 '07 #6
sicarie
4,677 Expert Mod 4TB
i am studing computer engineering
Haha, he's asking what you have tried to code so far. Are you familiar with functions? If not, this link, towards the bottom, is Banfa's explanation of functions. If you are, what have you tried and where are you getting stuck?
Mar 14 '07 #7
holla
22
OK, but what have you done in an attempt to solve this problem on your own? Are you having trouble with a part of it, or are you asking us to write the program for you?
i just can understand the whole thing so if u dont mind can u pls write the program for me
Mar 14 '07 #8
Ganon11
3,652 Expert 2GB
The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you. Attempt the assignment/program yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve.

Please read the Posting Guidelines and particularly the Coursework Posting Guidlines.

Then when you are ready post a new question in this thread.

MODERATOR
Mar 14 '07 #9
holla
22
The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you. Attempt the assignment/program yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve.

Please read the Posting Guidelines and particularly the Coursework Posting Guidlines.

Then when you are ready post a new question in this thread.

MODERATOR
thanx for ur time i shall give it a go ahead
Mar 14 '07 #10
roopal
2
i want a c coding for find a time complexity in sorting method?please help me.
Aug 30 '07 #11
Ganon11
3,652 Expert 2GB
Please ask your question in your own thread, rather than tacking it onto the end of another user's thread.
Aug 30 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Johnny Meredith | last post by:
Is there a function in VBA to convert a string to an array of characters. I'm looking for the exact same functionality as the ToCharArray() method in C#. If this functionality does not exist, do...
0
by: Nadav | last post by:
Hi All, - I am working on a tool that manipulate managed assemblies, some of the functionality provided by the tool require manipulating the metadata sections of the managed assembly in a way it...
14
by: Peter | last post by:
Is there a fast way to move data from DataTable into double array, or do I have to spin through every record and column? I have five tables and I need to merge these tables column wise, each table...
12
by: Sheldon | last post by:
Hi, I have two arrays that are of the same dimension but having 3 different values: 255, 1 or 2. I would like to set all the positions in both arrays having 255 to be equal, i.e., where one...
9
by: rkk | last post by:
Hi, I have written a generic mergesort program which is as below: --------------------------------------------------------- mergesort.h ----------------------- void MergeSort(void...
2
by: vssp | last post by:
hai friends I need one solution for multidimentional array merging option using php Please send me any samples multidimensional array merging __________________ Thanks Vssp
2
by: Akhenaten | last post by:
I have the following query I run to pull some data from the db. The sql (when run on the db) returns 2 elements. However, if I var dump my variable ($aidlook) then the first element in the array...
9
by: Nathan Sokalski | last post by:
I am trying to use the System.Array.ForEach method in VB.NET. The action that I want to perform on each of the Array values is: Private Function AddQuotes(ByVal value As String) As String Return...
1
by: chiefychf | last post by:
I'm working on a school project and I am having a few issues... The program calls for three arrays a,b,c that have to be sorted, then compared to even or odd and stored in arrays d & e, then merge...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.