473,472 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Arrays, searching for the MAX element, combining elements etc.

EARNEST
128 New Member
Hello everyone,

here is what I'm trying to do and what I managed to do. My question is if it is efficient and if I could improve the algorithm any further (without any overheads).

Situation:
1. List<double[]> list.
2. double[] arr.
Let's say
arr.Size = 20;
List.Capacity/Count = 50.

What I need to do is
1. Scan each arr[i] location and get the values
2. combine into array what we got3
3. find the maximum value

So...

tempArray[0] = Max(list[0..K-1], arr_loc = 0)
tempArray[1] = Max(list[0..K-1], arr_loc = 1)
etc

Here is my code:

Expand|Select|Wrap|Line Numbers
  1.         /// <summary>
  2.         /// simplest search (ala bubble sort)
  3.         /// </summary>
  4.         /// <param name="arrayToScan"></param>
  5.         /// <returns></returns>
  6.         internal double GetMaxValue(double[] arrayToScan)
  7.         {
  8.             double temp = 0;
  9.  
  10.             for (int i = 0; i < arrayToScan.Length; i++)
  11.             {
  12.                 if (arrayToScan[i] > temp)
  13.                 {
  14.                     temp = arrayToScan[i];
  15.                 }
  16.             }
  17.  
  18.             return temp;
  19.         }
Expand|Select|Wrap|Line Numbers
  1.              internal double[] AggregationMethod(List<double[]> listOf_doubleArr)
  2.         {
  3.             double[] temp;
  4.             double[] aggregatedArrays;
  5.  
  6.             temp = new double[listOf_doubleArr[0].Length];
  7.             aggregatedArrays = new double[listOf_doubleArr.Count];
  8.  
  9.             for (int i = 0; i < listOf_doubleArr[0].Length; i++) // 41
  10.             {
  11.                 for (int j = 0; j < listOf_doubleArr.Count; j++) //17
  12.                 {
  13.                     aggregatedArrays[j] = listOf_doubleArr[j][i];
  14.                 }
  15.                 temp[i] = GetMaxValue(aggregatedArrays);
  16.               // Console.WriteLine(listOf_doubleArry[0][i]);
  17.             }
  18.             return temp;
  19.         }
  20.  
Dec 25 '10 #1
0 964

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

Similar topics

38
by: ssg31415926 | last post by:
I need to compare two string arrays defined as string such that the two arrays are equal if the contents of the two are the same, where order doesn't matter and every element must be unique. ...
3
by: gj785 | last post by:
Ok so I've got this problem for a programming class; and I can't seem to figure it out. I've got a bunch of random numbers (say test scores). Now I need to program the code so that the user can...
3
by: Andy B | last post by:
I need to search an xml element for blocks of text. The start of the text block will have a 5 digit number in it and i then need to read until the next 5 digit number. After this, I need to put...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.