For example, return the coordinates (-1, 1) (0,0) (1,1) and (1,2) from the following cartesian plane

# Tag: List

## When would you use an edge list graph data structure instead of an adjacency list or adjacency matrix?

In what applications would you choose an edge list over an adjacency list or an adjacency matrix?

Sample Question, VisuAlgo:Which best graph DS(es) should you use to store a simple undirected graph with 200 vertices, 19900 edges, and the edges need to be sorted? Suppose your computer only has enough memory to store 40000 entries.

There are three choices: adjacency lists, adjacency matrix, and an **edge list**.

Edge lists are the correct answer here because sorting by weight is most efficient, but what are some other use cases?

Thanks!

## Auto Upload verified list to hoster

## What is the difference between python list and c++ vector?

I read about the similarities between the python list and c++ vector and it looks as if the only difference is python list is heterogeneous. Are there any other differences? How are they both implemented?

## A reduction from $HP$ to $\{(\langle M \rangle, \langle k \rangle) : \text{M visits in at list $k$ states for any input}\}$

I tried to define the next reduction from $ HP$ to $ \{(\langle M \rangle, \langle k \rangle) : \text{M visits in at list $ k$ states for any input}\}$ .

Given a couple $ (\langle M\rangle , \langle x\rangle)$ we define $ M_x$ such that for any input $ y$ , $ M_x$ simulates $ M$ on the input $ x$ . We denote $ Q_M +c$ the number of states needed for the simulation of $ M$ on $ x$ , and define more special states for $ M_x$ $ q_1′,q_2′,…,q_{Q_M + c+ 1}’$ when $ q’_{Q_M +c+1}$ is defined as the only final state of $ M_x$ . Now, in case $ M_x$ simulation of $ M$ on $ x$ halts (i.e $ M$ reach one of its finite state) $ M_x$ move to $ q_1’$ and then continue to walk through all the special states till it reaches $ q_{Q_M + c + 1}$ .

We define the reduction $ (\langle M \rangle , \langle x \rangle) \longrightarrow (\langle M_x \rangle , \langle Q_M +c+1 \rangle)$

In case $ ((\langle M \rangle , \langle x \rangle) \in HP$ then for any input $ y$ , $ M_x$ walks through all the special states and thus visits in at least $ Q_m + c+ 1$ steps. Otherwise, $ M$ doesn’t stop on $ x$ so $ M_x$ doesn’t visit any special state, thus visits at most $ Q_M +c$ states (the states needed for the simulation).

It is ok? If you have other ideas or suggestions please let me know.

## How do I write a tooltip for this list of cities?

`distanceToSanFrancisco[s_] := QuantityMagnitude[ TravelDistance[cityList[[859]], Interpreter["City"][s]]] (* table1 takes a while to run on my system*) table1 = Table[{cityList[[k]], distanceToSanFrancisco[cityList[[k]]]}, {k, Length[cityList]}]; citiesWithin[range_] := Module[{s = {}}, Do[If[table1[[k, 2]] <= range, s = Join[s, {cityList[[k]]}]], {k, Length[cityList]}]; s] (*This lists all cities in California that are within `range` of San Francisco.*) radius = 25; tolerance = 0.05; a1 = GeoDisk[ QuantityMagnitude[ LatitudeLongitude[Interpreter["City"]["San Francisco"]]], Quantity[radius, "Miles"]]; a3 = Complement[ citiesWithin[radius*(1 + tolerance)], citiesWithin[radius*(1 - tolerance)] ]; Table[a3[[k]] -> distanceToSanFrancisco[a3[[k]]], {k, 1, Length[a3]}] Show[a2, GeoListPlot[a3, PlotMarkers -> Point], ImageSize -> Medium] `

This last one is what I want the tooltips on. For the red points around San Francisco, ideally I would like to get just city name. TIA

## What is the theoretical result of flattening a list containing only itself?

Consider the following python code

`X = [None] X[0] = X `

This has many fun properties such as

`X[0] == X `

and

`X[0][0][0][0][0][0][0][0] == X `

I understand how this works from a practical standpoint, as it’s all just the same pointer.

Now, when flattening a list, we tend to convert things from

`[[1, 2, 3], [[4, 5], [6, 7]], 8, 9] `

to

`[1, 2, 3, 4, 5, 6, 7, 8, 9] `

In this case, I am considering flattening to be reducing a multi-dimensional list down to a single list of only non-list elements.

In practice, flattening this list would be impossible, as it would create an infinite loop.

This may be more mathematical in nature, but I’m unsure how to put it in mathematical terms. Suppose we could flatten this list, would the result simply be the empty list?

For context, I initially got this idea by considering the list

`X = [[], []] X[0] = X `

It is clear to see that at each *pass* of flattening, the empty list that is the second element simply disappears. This lead me to think that the overall result, may be the empty list.

Could it be possible that flattening this list would theoretically produce an infinitely long list of the list itself, as in

`X == [X, X, X, X, X, X, ..., X] `

This is purely a fun thought exercise. Any insight and discussion on this would be appreciated.

P.S. Although I’m looking for an answer in plain terms, if anyone is more mathematically inclined, I would be interested to see how this problem could be formulated in some sort of set notation. Please feel free to point me to a relevant math exchange thread as well.

P.P.S. I would also be interested in a solid proof (not formal) to go along with the answer.

## How to manipulate solution outputs that appear in a list?

I have a list `{E, {p, ϕ}}`

, and I need values `E`

, `p`

, and `ϕ`

such that I can later on do operations with them (like `ArcCos[p]`

, etc.). I will be repeatedly generating the values in the list, as a list, so doing this by-hand is not an option. How do I get them out of the list?

In this case, the values `E`

, `p`

, and `ϕ`

exist such that they appear as `p -> 0.097`

, `ϕ -> 0.03`

, etc. I need them such that calling, for example, for `list = {E, {p, ϕ}}`

, `list[[2,1]]`

yields `0.097`

and not `p -> 0.097`

. This is the issue.

## Post count doesn’t match number of posts shown in list in admin

Please check below screenshot and let me know how is this possible.

If I am logged in blog page shows 3 posts on page, if logged out then it shows 4 posts

## Table Filtering Using Big List

Briefly, I am trying to filter a table using conditions plus a list of items in Oracle. In detail, I have a reporting table which has millons of records. I would like to filter it using external lists which might include more than 1000 lines of fields from the record table. (Obviously, I especially said 1000, because `in clause`

in Oracle has the limit of 1000 items). So my question is; How can I effectively filter a huge table using another big list.