Confused about how APIs are called

I’m new to APIs. Conceptually, I understand what an API is, but I get confused when it comes to the some of the technical details.

All of the tutorials I’ve read talk about URLs and endpoints, and they describe them as being the paths/addresses through which APIs can be accessed. This part is very clear; no confusion here.

However, what I don’t understand is how APIs are called. In other words, in a real-world scenario, people don’t actually type in a URL in some input box to call APIs, so I assume the calling is done behind the scenes, by some program, and in response to some trigger event? If my assumption is true, is it also true that when using a client like Postman to test APIs, you are basically emulating the behavior of said program?

Lastly, where are APIs typically stored?

Confused by website behaviour [on hold]

I am currently crawling for all of its products when I realised something. You can navigate through all of the pages of the women’s products through changing the page number on this link: (page no.17). However, if you enter any page number greater than 429, the link redirects to page 429. On the other hand, when I physically click the next page button on page 429, it takes me to page 430, even though the button just provides the next link ( How does the website know if I pressed the button or if I went directly to the link.

Any help would be greatly appreciated 🙂

Confused about the notion of object definition in python [on hold]

I have read somewhere that “Every python object is a value having a certain type stored at a particular memory location”.The other definition of a python object is each object has a type, an identity, and a value. According to this definition, we would think of an object as a thing holding a value(a rectangular box containing integer value 36 for instance and the entire thing will be called an object, not just the value 36)which is not true when we say 36 is itself an object and there is no such thing containing 36. It does not sound good that int object 36 has an identity(id(36), type int and 36 has a value of 36. This is according to the 2nd definition so both definitions contradict? Please help

Macbook gets confused by switching external USB keyboard

I have two different locations to use my MacBook pro and attach an external USB keyboard at both places. They are both 104keys and have identical layouts.

When I first plug in the keyboard it often (not always) stops working properly. The modifier keys will be completely incorrect and then most of the regular keys are also translated improperly.

What I have been doing is mess around with the laptop builtin keyboard a bit then back and forth for a while (tens of seconds to a minute or so) before the keyboard functionality usually gets back to normal.

I have not been able to settle on a pattern that reliably works any better than the above – which is messy and moderately unpredictable.

Has anyone run into this and come up with a better solution?

Confused with the proof that Edmonds-Karp always monotically increases the shortest-paths

The proof for the lemma from “Introduction to Algorithms by Cormen et. al.” is not clear for me. I can’t comprehend a few things. Here is a lemma and its proof. My questions are below.

The notation $ \delta(u, v)$ is used to denote shortest-path from $ u$ to $ v$ .

lemma proof1 proof2

My questions are:

Because of how we chose $ v$ , we know that the distance of vertex $ u$ from the source $ s$ did not decrease, i.e., $ \delta_{f’}(s, u) \geq \delta_{f}(s, u)$

Why the shortest-path from $ s$ to $ u$ after the augmentation of flow $ f$ must be greater than or equal to the distance before the augmentation ? How it is possible to have greater distance that it was ? The augmentation only removes the edge $ (u, v)$ . But, the vertex $ u$ still in place, isn’t it must be strictly equal ?

If we had $ (u, v) \in E_f$ , then we would also have $ \delta_f(s,v) \leq \delta_f(s, u) + 1$

This looks like ok for me to have such case. We claim that distance from $ s$ to $ v$ is less than or equal to the distance from $ s$ to $ u$ plus 1. But in the graph before the first augmentation this case must be true. It is false for less than case, but true for equal case.

How can we have $ (u, v) \notin E_f$ and $ (u, v) \in E_{f’}$ ? The augmentation must have increased the flow from $ v$ to $ u$ . The Edmonds-Karp algorithm always augments flow along shortest paths, and therefore the shortest path from $ s$ to $ u$ in $ G_f$ has $ (v, u)$ as its last edge.

The edge set $ E_f$ is before the first augmentation and $ E_{f’}$ is after it. The first augmentation must remove the edge $ (u, v)$ and put the reverse edge $ (v, u)$ into the edge set $ E_{f’}$ , but not the same edge $ (u, v)$ . That is why how we can have $ (u, v)$ in $ E_{f’}$ ?

I am so confused about postfix and prefix expressions and side-effects in C

I am a freshman in the computer science right now. Actually, I have been learning C and other kinds of programming since I was about first grade in high school.

I am learning about the Postfix and Prefix Expressions right now.

I am using GCC and Xcode for my personal development environment. However, in school, we use Visual Studio 2017. And the result comes out different in both compilers. So I am pretty much confused how I can understand this. I have been googling this question, but haven’t found any answers yet, so I am posting a question here. (If this post is inappropriate or already has an answer, then let me know.)

Let’s say that we have a code in C99.

int a;  int b;  a = 10; b = a++ + a++;  printf("Value of a is %d\n" , a); printf("Value of b is %d\n" , b); 

I skipped preprocessor part and main function part to save some space. Also, I do know that using those expressions to evaluate ‘b’ is not a good way.

In GCC Environment

Value of a is 12 Value of b is 21 

In Visual Studio Environment

Value of a is 12 Value of b is 20 

What I have figured out and understood is that, In GCC, ‘b’ is evaluated like this; 10 + 11 = 21 In Visual Studio, ‘b’ is evaluated like this; 10 + 10 = 22;

In GCC, I think the calculation process is done like this.

  1. Got value from variable (a = 10)
  2. Added 1 to the variable (a = 11)
  3. Got value from variable (a = 11)
  4. Added 1 to the variable (a = 12)

So, it is done 10 + 11 = 21 in this case.

However, in Visual Studio, I think the calculation process is done like this.

  1. Got the value from the variable (a = 10)
  2. Got the value from the variable (a = 10)
  3. Added 1 to the variable (a = 11)
  4. Added 1 to the variable (a = 12)

So, it is done 10 + 10 = 20 in this case.

The first question is, Am I understanding this correctly?

I have learned from the textbook that, side-effect comes after the ;(semicolon). In that case, it matches the Visual Studio case. However, It does not seem to fit in the GCC case in my opinion since the side-effect came before the semicolon.

The second question is, So, does the timing when side-effect comes vary between compilers?

Since I live in Korea, where we do not use English as native language, so I might sound little strange. I hope your understanding. And also, I do not know how compiler works, so I might say something different and wrong.

Thanks for reading this long question. Have a Nice day!

Confused about constructing the “failure table” in Knuth-Morris-Pratt algorithm

I’m trying to learn how the “failure table” is constructed in the Knuth-Morris-Pratt algorithm since it seemed nontrivial to me that you could do it in $ O(k)$ time (where $ k$ is the length of the pattern, $ W$ ). To be clear, we let the failure table $ T$ be a length $ k$ array where $ T[i]$ is the length of the longest proper prefix of $ W$ which is also a suffix of $ W[1]\cdots W[i]$ .

I was trying to understand it better by reading the following code:

    vector<int> T(pattern.size());     T[0] = 0;     int j;     for (int i = 1; i < pattern.size(); i++) {         j = T[i - 1];         // Find largest j s.t. T[:j+1] == T[i-j:i+1]         while (j > 0 && pattern[j] != pattern[i]) {             j = T[j - 1];         }         T[i] = (pattern[j] == pattern[i]) ? j + 1 : j;     }     return T; 

The part I’m confused about is why pattern[j] == pattern[i] is enough to guarantee that $ T[i] = j + 1$ . I was trying to prove this inductively but have had no luck. I’ve phrased the problem as follows:

Suppose $ W[1]\cdots W[T[i – 1]] = W[i – T[i – 1]]\cdots W[i – 1]$ . If $ W[i] == W[j]$ , then is it true that $ W[1]\cdots W[j] == W[i – j + 1]\cdots W[i]$ ?

I can’t make any headway with this, nor can I see why it should be true. It still seems like we have to check $ W[\ell] = W[i – j + \ell]$ for all $ \ell = 1…j$ . I can’t figure out how to use the inductive hypothesis to prove this result. Do I have to use strong induction (where we assume all prior steps are true and not just the previous step) to prove this?

Confused with specific SQL query, AvgPrice

Please let me know if this is correct, and if not, what the correct or best way to write the SQL query would be. I am a beginner so I apologise if this is obvious to you. I believe I have to use a JOIN but unsure how.

THIS IS ONLY ASKING ABOUT QUESTION C) Get the average price of products produced by each product line. Name the average price “AvgPrice”.

my db layout

  SELECT AVG(price) AS "AvgPrice"     FROM product_line GROUP BY product_line;