[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

Algorithms

An algorithm is a self-contained step-by-step set of operations to be performed. Algorithms exist that perform calculation, data processing, and automated reasoning. Starting from an initial state and initial input (perhaps empty), the instructions describe a computation that, when executed, proceeds through a finite number of well-defined successive states, eventually producing "output" and terminating at a final ending state. The transition from one state to the next is not necessarily deterministic; some algorithms, known as randomized algorithms, incorporate random input.

Share tech news, updates, or what's on your mind.

Sign up to Post

What does       O(n2) algorithm mean? and How to test it to show running time?
0
HTML5 and CSS3 Fundamentals
LVL 12
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

Algorithm question
Suppose an O(n3) function takes 10 seconds to work on a dataset of size n=400.  How long would we expect this function to execute on a dataset of size n=800?
0
I need some help coming up with a present value formula to calculate what we call in our industry the true interest cost of debt or TIC.   In the attached file is the calculation produced by software that we use however it does not provide formulas.   I would like to come up with a spreadsheet that I can use to calculate TIC on my own.   About the spreadsheet that I have provided.   At the top is the solution to the cash flows below.   The dated date is the date that interest begins on the loan the TIC is the effective borrowing rate or the rate necessary to discount the amounts payable on the respective principal and interest payment dates to the purchase price (loan amount) received assuming compounded semi-annually.   The first column is the dates payments are made, the second column is the amount of debt paid each semi period and the third column is the discount column calculated by the software to come up with the TIC (discount rate) that equals the target amount above of $10,513,798.96.  I would like to setup a spreadsheet that will allow me to calculate on my on the TIC.  Meaning if I know the target amount, Dated Date, and semi-annual cash flows the spreadsheet will calculate the TIC that discounts those cash flows so that they equal the target amount.  I have tried using the IRR function but it did not work for me.  Hoping to get other ideas how to set this up using this example to check that it works by trying to recreate the answer.  I hope this make sense but …
0
Can someone explain to me where consensus algorithms fit within the TCP/IP model?  Let use Raft as an example.  Does it use multicast?  Does it use it's own transport number or TCP/UDP?  Does it live on the application layer?

Thanks
0
Hi,

I am practicing some algorithm to merge 2 existing arrays.
Here are the requirements I created:
1. no Linq allowed.
2. no concat, copyTo. Array.Sort() method allowed.
3. result should be sorted by ascending order.

I actually completed the coding, but there must be much better solution.
I also had to create Sort method to sort the result array.
Is there anyway I can sort while merging?

Currently I am Merging and then Sorting.


 
static void Main(string[] args)
        {

            int[] a = { 1, 2, 3 };
            int[] b = { 1, 2, 3 };

            int[] result = Sort(MergeTwoArrays(a, b));
            foreach (var item in result)
            {
                Console.Write(item+ " ");
            }           

            Console.Read();
        }

        public static int[] MergeTwoArrays(int[] a, int[]b)
        {
            int aLength = a.Length;
            int bLength = b.Length;
            int totalLength = aLength + bLength;
            int[] c = new int[totalLength];

            for (int i = 0; i < a.Length; i++)
            {
                c[i] = a[i];
            }
            int k = a.Length;
            for (int i = 0; i < b.Length; i++)
            {
                c[k] = b[i];
                k++;
            }
            return c;
        }

        public static int[] Sort(int[] a)
        {
            int i, j, temp, minIndex;
            for (i = 0; i < a.Length; i++)
            {
                minIndex = i;
    

Open in new window

0
I've been using the Azure ML Studio and it is great.

I get the basics of what ML is and what it does. But now I'd like to learn it in more detail - understand the deeper issues, the math behind it, what the different algorithms do and so on.

But I don't know where to go for this. Most of the introductions to ML use Python and TensorFlow. Ideally I'd like to stick to Azure ML Studio but I just can't find anything that tells me about the theory of ML rather than how to use Azure ML Studio.

I'm talking about books or courses - I think ideally a book but either would be fine.

This book might be promising:

Predictive Analytics with Microsoft Azure Machine Learning 2nd Edition Paperback – 19 Aug 2015
by Valentine Fontama (Author), Roger Barga (Contributor), Wee Hyong Tok (Contributor)

But I'm concerned it doesn't give the background - the reviews seem to indicate this.

Let me know if you have read a good book or completed a good course that explains the math of ML and would be something I could use with the Azure ML Studio.

Thanks!
0
Need to search find closest match in array of strings

I have a static list of about 500 strings containing things like:

VS Credit Voucher Proc-CR Trans 2
VS Credit Voucher Proc-OB Prepaid Trans 2

but am reading from OCR and get the strings from the faxed reports looking like:

VS Credit Voucher Proc-CR Trans 2
VS Crect Voucher Proc-OBPrepaid Trar 2

I need to do a lookup for the best match for each as it appears in the in the static list.

And of course, there needs to be a threshold where NO MATCH is a possibility.

How shall I store the static list? How can I do a search in the list that is resource efficient?

I would sort that list of 500, clearly. But what are the mechanics of the lookup?

I am writing a C# Win Forms (64 bit) application and could include a database, if I could include that into my EXE, to avoid a distinct installation step.

What search algorithm?
 
Thanks.
0
I am considering whether the starting position for the pattern vis-a-vis the searched text,  (i.e. the LAST CHARACTER of the pattern be aligned) ought to initially coincide with the first appearance of that LAST CHARACTER in the searched Text, *provided that appearance is equal to or more than the length of the Pattern*, since otherwise the index would have occurred too early in the sequence to be valid.

Consider this illustration from the B-M paper :

Search starting alignment
The B-M algo would 'mismatch' the final T from the 'pat' with the F from the 'string', and move the pattern past the F, to align the A with the I. Whereas the first contending T in the pattern and the string is at index 17 in the string, rather than the standing comparison being done at index 7.
0
Are there any comments anyone would like to make that would flatter or support any particular approach to String search methodology and algorithms ? Are there any algorithms which can be applied to several search conditions and requirements ? All comments welcomed. Thanks, k.
0
Request help from the experts to suggest the best name matching algorithm, logic description and code to reuse for executing name matching function - java or excel can do..
0
Exploring ASP.NET Core: Fundamentals
LVL 12
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Implement an algorithm as method to take a BST and convert it to a mirror tree where left and right subtrees are interchanged.
and print BST each level in separate line
All coding should be in Python
0
Dear experts,

I have learnt about GeoGebra app while learning about One note from one of the Youtube videos.

I have tried it and i see that produces good charts. But it does not the values used in the x variable to calculate the Y value.

In the attached screen dump I have shown the table calculated by me. the function graph has been copy[-pasted from Geogebra.

CAn you someone please guide me to a app/url which plot the function and shows the table.

Thank you
WhatsApp-Image-2018-04-13-at-07.07..jpeg
0
Explain Big O notation, Binary Search and Logarithms, C#

I am curious to learn more about Big O, Binary Search and huge data sets.

What sorting and searching methods maximize performance for millions of records?

Is Binary Search still used here?

Thanks

https://codingticks.wordpress.com/2013/07/21/a-beginners-guide-to-big-o-notation/
0
Need exercises on the Big O Notation

I have engineering optimization on various software projects in the past, but need to pass a test which will evaluate my skills solving the Big O Notation.

I will need to code in C# with arrays, data sets and the like as a way to show I can optimize code.

Any exercises I could play around with?

Thanks.
0
Dual pipe producer/consumer blocked by read.

The issue is in the producer:
        read(consumer_to_producer[0], &cnt, sizeof(cnt));
        read(consumer_to_producer[0], shared_arr, sizeof(shared_arr));

Open in new window

prevents the producer from working because the consumer has yet to write anything, how can I avoid this?


#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#define SIZE 10

int shared_arr[SIZE];
int cnt = 0, in = 0, out = 0;
int consumer_to_producer[2], producer_to_consumer[2];

void consumer();
void producer();

int main() {
    pipe(consumer_to_producer); // consumer to producer
    pipe(producer_to_consumer); // producer to consumer

    if (fork() == 0) {
        /* child process */
        consumer();
    } else {
        /* parent process */
        producer();
        sleep(3);
    }

    exit(0);
}

void consumer() {
    /* consumer process */
    close(producer_to_consumer[1]); // Close write end, we don't need it
    close(consumer_to_producer[0]); // This fcn doesn't need read end
    while (1) { 
        /* if buffer is full, consume it */
        // read in cnt from producer so we can check if it's full
        read(producer_to_consumer[0], &cnt, sizeof(cnt));

        if (cnt == SIZE) { /* If full, consume */
            read(producer_to_consumer[0], shared_arr, sizeof(shared_arr));
            printf("I am consuming\t%d\t%d\n", shared_arr[in], out);
            out = (out + 1) % SIZE;
            cnt--;
        } 

        

Open in new window

0
I have found this below function for deleting a node from Linked List from the book named [DATA STRUCTURE AND ALGORITHMS MADE EASY](https://www.amazon.in/Data-Structures-Algorithms-Made-Easy-ebook/dp/B01N4OA309?tag=googinhydr18418-21)


The code is:-
void DeleteFromLinkedList(struct ListNode **head, int position){
int k=1;
struct ListNode *p, *q;
if(*head==NULL){
printf("List Empty");
return;
}
p=*head;
//from the beginning
if(position==1){
*head=(*head)->next;
free(p);
return;
}

else{
//Traverse the list until arriving at the position from which we want to delete
while((p!=NULL) && (k<position)){
k++;
q=p;
p=p->next;
}
if(p==NULL) //At the end
printf("Position does not exist");
else{  //From the middle
q->next=p->next;
free(p);
}
}
}

Open in new window


Now my question is what is the meaning of
(k<position)

Open in new window

here what is the purpose of using this
 (k<position)

Open in new window

and wh at is the use of
intk=1;

Open in new window


please explain me in detail the above code.
0
I'd like to write a Lambda function that fetches a (1) CloudWatch Metric (that is already being monitored at every 5 minutes), (2) divides that value by 300 seconds and (3) pushes to CloudWatch as a Custom Metric.

The CloudWatch metrics already being monitored are "Volume Read Ops" and "Volume Write Ops" on a could different active EBS volumes.

I have no every on using Java or Python for this.

Thanks for your help or pointing me in the right direction.
0
I need to prove that certain patterns were engineered and not random events and have been told that Neural Networks can be used to help make this determination.

What kinds of tools and algorithms should I be looking at?

Any sample projects that have done something similar?
0
If we consider the included image, namely that the structure of the binary data obtained after treatment seems to be completely regular and more repeated in similar parts until the end of the file, can we consider being able to definitively free ourselves from identical elements within each slice and thus no longer need to store them?
Re-Scheduling the Binary Structure of a File to Reduce its Final Volume

Thank in advance for your opinion .. ... .....

Best regards,
0
Fundamentals of JavaScript
LVL 12
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

Seo
We take a look at the fast-evolving changes in Search Engine Optimization rules and algorithms by Google.
0
C++03 using VS 2010. (Assume no boost available.)

I would like to find the missing points in the below diagram using C++03 std lib. The x's represent a set of given points, and the o's are the missing points.

x----o--x----x---o
|    |  |    |   |
o----o--x----o---x
|    |  |    |   |
o----x--x----o---x
|    |  |    |   |
x----o--x----o---o
|    |  |    |   |
x----x--o----o---o
|    |  |    |   |
o----o--x----o---o

Open in new window

I am given a set of points Pi = (Xi, Yi). The coordinates are of type double. If I were to draw a grid (consisting of horizontal and vertical lines) going though every point, I may have some missing points as shown above.

The result should be a std container having the (X, Y) points that are missing.

I suspect that http://www.cplusplus.com/reference/algorithm/set_difference/ or some variation might be useful. So getting the entire list of potential points somehow is probably also useful. Although speed is always a plus, it is not essential.

Any code suggestions?

BTW - there are NOT going to be any tricky points - like a point very far away from the main set of points.
BTW - I've been using axis indices to represent the actual axis coordinate values (but don't worry about that if it complicates the code).

I can probably do this using brute force using a 2D array; so the purpose of this question is to use std lib algorithm functions to simplify the code and hopefully improve performance.
0
I am learning the BigO notation and I have a question which is related to homework:

def __str__(self):
return str(self.list)

Open in new window


If I cast an object, does Python iterate over it?
That is, would I have a O(n) here or is it just O(1)?

Thanks for your help
0
Consider algos/softwares that take keywords in one document and match them (possibly a kind of set intersection) with keywords in N other documents, possibly producing a match ranking.

a. Is there a specific name for this?
b. Are there implementations in Java and PHP?

Example use cases would be
  • patients submitting a list of symptoms and then software looking for matches against known conditions
  • applicants submitting skillsets and looking for potential job matches
  • dating websites
0
Hello,

       I am running through the securing TCP/IP of the N10-06 certification and having difficulty understanding the use of Hash. I get the process of using the algorithm to change the data, but what I don't understand is how that is applied and how it is decrypted on the receiving side to get the data. I have read that it is a One-Way system and cannot be decrypted, but if that is the case how does the recipient decrypt it? Is there a public key sent with the hash and what portion of my computer actually does the decryption. I've been Googling on this a while and reading Mike Myers book as well as Professor Messers video on it, but I am only getting vague descriptions on the intent and concept but not how its staged and executed. Does anyone have any sage advice on this?

Thanks!
0
Dear Experts,

Actually trying to analyze the machine learning logics behind in algorithms, for example the KNeighborsClassifier():

import pandas
from sklearn.neighbors import KNeighborsClassifier
model = KNeighborsClassifier()
print(model)

Open in new window


Could you please advise would it be possible to list the content of an algorithm in Python and with which syntax concretely? The above print(model) of course just provides some overall information about the algorithm, but not the content

Thanks in advance,
0

Algorithms

An algorithm is a self-contained step-by-step set of operations to be performed. Algorithms exist that perform calculation, data processing, and automated reasoning. Starting from an initial state and initial input (perhaps empty), the instructions describe a computation that, when executed, proceeds through a finite number of well-defined successive states, eventually producing "output" and terminating at a final ending state. The transition from one state to the next is not necessarily deterministic; some algorithms, known as randomized algorithms, incorporate random input.

Top Experts In
Algorithms
<
Monthly
>